mirror of
https://github.com/nathom/streamrip.git
synced 2025-05-15 07:34:48 -04:00
Add support for Youtube video downloads
This commit is contained in:
parent
7347330a42
commit
201065516d
4 changed files with 34 additions and 5 deletions
|
@ -957,13 +957,19 @@ class YoutubeVideo:
|
||||||
"""Dummy class implemented for consistency with the Media API."""
|
"""Dummy class implemented for consistency with the Media API."""
|
||||||
|
|
||||||
class DummyClient:
|
class DummyClient:
|
||||||
source = 'youtube'
|
source = "youtube"
|
||||||
|
|
||||||
def __init__(self, url: str):
|
def __init__(self, url: str):
|
||||||
self.url = url
|
self.url = url
|
||||||
self.client = self.DummyClient()
|
self.client = self.DummyClient()
|
||||||
|
|
||||||
def download(self, parent_folder='StreamripDownloads', **kwargs):
|
def download(
|
||||||
|
self,
|
||||||
|
parent_folder="StreamripDownloads",
|
||||||
|
download_youtube_videos=False,
|
||||||
|
youtube_video_downloads_folder="StreamripDownloads",
|
||||||
|
**kwargs,
|
||||||
|
):
|
||||||
filename_formatter = "%(track_number)s.%(track)s.%(container)s"
|
filename_formatter = "%(track_number)s.%(track)s.%(container)s"
|
||||||
filename = os.path.join(parent_folder, filename_formatter)
|
filename = os.path.join(parent_folder, filename_formatter)
|
||||||
|
|
||||||
|
@ -980,6 +986,20 @@ class YoutubeVideo:
|
||||||
self.url,
|
self.url,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
print(f"{download_youtube_videos=}")
|
||||||
|
if download_youtube_videos:
|
||||||
|
pv = subprocess.Popen(
|
||||||
|
[
|
||||||
|
"youtube-dl",
|
||||||
|
"-o",
|
||||||
|
os.path.join(
|
||||||
|
youtube_video_downloads_folder, "%(title)s.%(container)s"
|
||||||
|
),
|
||||||
|
self.url,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
pv.wait()
|
||||||
p.wait()
|
p.wait()
|
||||||
|
|
||||||
def load_meta(self, *args, **kwargs):
|
def load_meta(self, *args, **kwargs):
|
||||||
|
|
|
@ -71,6 +71,8 @@ class Config:
|
||||||
},
|
},
|
||||||
"youtube": {
|
"youtube": {
|
||||||
"quality": 0,
|
"quality": 0,
|
||||||
|
"download_videos": False,
|
||||||
|
"video_downloads_folder": DOWNLOADS_DIR,
|
||||||
},
|
},
|
||||||
"database": {"enabled": True, "path": None},
|
"database": {"enabled": True, "path": None},
|
||||||
"conversion": {
|
"conversion": {
|
||||||
|
|
|
@ -12,7 +12,8 @@ CONFIG_PATH = os.path.join(CONFIG_DIR, "config.yaml")
|
||||||
LOG_DIR = click.get_app_dir(APPNAME)
|
LOG_DIR = click.get_app_dir(APPNAME)
|
||||||
DB_PATH = os.path.join(LOG_DIR, "downloads.db")
|
DB_PATH = os.path.join(LOG_DIR, "downloads.db")
|
||||||
|
|
||||||
DOWNLOADS_DIR = os.path.join(Path.home(), "StreamripDownloads")
|
HOME = Path.home()
|
||||||
|
DOWNLOADS_DIR = os.path.join(HOME, "StreamripDownloads")
|
||||||
|
|
||||||
AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:83.0) Gecko/20100101 Firefox/83.0"
|
AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:83.0) Gecko/20100101 Firefox/83.0"
|
||||||
|
|
||||||
|
@ -145,7 +146,7 @@ LASTFM_URL_REGEX = r"https://www.last.fm/user/\w+/playlists/\w+"
|
||||||
QOBUZ_INTERPRETER_URL_REGEX = (
|
QOBUZ_INTERPRETER_URL_REGEX = (
|
||||||
r"https?://www\.qobuz\.com/\w\w-\w\w/interpreter/[-\w]+/[-\w]+"
|
r"https?://www\.qobuz\.com/\w\w-\w\w/interpreter/[-\w]+/[-\w]+"
|
||||||
)
|
)
|
||||||
YOUTUBE_URL_REGEX = r"https://www\.youtube\.com/watch\?v=\w+"
|
YOUTUBE_URL_REGEX = r"https://www\.youtube\.com/watch\?v=[-\w]+"
|
||||||
|
|
||||||
TIDAL_MAX_Q = 7
|
TIDAL_MAX_Q = 7
|
||||||
|
|
||||||
|
|
|
@ -147,6 +147,12 @@ class MusicDL(list):
|
||||||
],
|
],
|
||||||
"download_videos": self.config.session["tidal"]["download_videos"],
|
"download_videos": self.config.session["tidal"]["download_videos"],
|
||||||
"download_booklets": self.config.session["qobuz"]["download_booklets"],
|
"download_booklets": self.config.session["qobuz"]["download_booklets"],
|
||||||
|
"download_youtube_videos": self.config.session["youtube"][
|
||||||
|
"download_videos"
|
||||||
|
],
|
||||||
|
"youtube_video_downloads_folder": self.config.session["youtube"][
|
||||||
|
"video_downloads_folder"
|
||||||
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
def download(self):
|
def download(self):
|
||||||
|
@ -169,7 +175,7 @@ class MusicDL(list):
|
||||||
)
|
)
|
||||||
click.secho("rip config --reset ", fg="yellow", nl=False)
|
click.secho("rip config --reset ", fg="yellow", nl=False)
|
||||||
click.secho("to reset it. You will need to log in again.", fg="red")
|
click.secho("to reset it. You will need to log in again.", fg="red")
|
||||||
logger.debug(err)
|
click.secho(err, fg='red')
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
logger.debug("Arguments from config: %s", arguments)
|
logger.debug("Arguments from config: %s", arguments)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue