Add SoundCloud
This commit is contained in:
parent
f8e214d0a2
commit
7a75805423
4 changed files with 19 additions and 5 deletions
|
@ -23,6 +23,9 @@ class Config:
|
||||||
# Proxy URL for yt_proxied downloader (can be used for geo-restricted content)
|
# Proxy URL for yt_proxied downloader (can be used for geo-restricted content)
|
||||||
self.yt_proxy = os.getenv('YT_PROXY') or None
|
self.yt_proxy = os.getenv('YT_PROXY') or None
|
||||||
|
|
||||||
|
# Proxy for soundcloud
|
||||||
|
self.sc_proxy = os.getenv('SC_PROXY') or None
|
||||||
|
|
||||||
self.save_lyrics = _parse_bool(os.getenv('SAVE_LYRICS'), True)
|
self.save_lyrics = _parse_bool(os.getenv('SAVE_LYRICS'), True)
|
||||||
self.save_cover = _parse_bool(os.getenv('SAVE_COVER'), True)
|
self.save_cover = _parse_bool(os.getenv('SAVE_COVER'), True)
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ class InfoYouTubePP(PostProcessor):
|
||||||
if not 'track' in information:
|
if not 'track' in information:
|
||||||
information['track'] = information['title']
|
information['track'] = information['title']
|
||||||
if not 'artist' in information:
|
if not 'artist' in information:
|
||||||
information['artist'] = information['channel'].removesuffix(' - Topic')
|
information['artist'] = information['uploader'].removesuffix(' - Topic')
|
||||||
if not 'artists' in information:
|
if not 'artists' in information:
|
||||||
information['artists'] = [information['artist']]
|
information['artists'] = [information['artist']]
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,16 @@ class _CreateYDL:
|
||||||
ydl.params['proxy'] = proxy
|
ydl.params['proxy'] = proxy
|
||||||
return ydl
|
return ydl
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def soundcloud() -> YoutubeDL:
|
||||||
|
ydl = YoutubeDL({'format': 'ba[ext=mp3]/ba'})
|
||||||
|
ydl.add_post_processor(id3pp.InfoYouTubePP(), when='pre_process')
|
||||||
|
proxy = config.get().sc_proxy
|
||||||
|
if proxy is not None:
|
||||||
|
ydl.params['proxy'] = proxy
|
||||||
|
ydl.add_post_processor(FFmpegExtractAudioPP(preferredcodec='mp3'), when='post_process')
|
||||||
|
return ydl
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def yandex() -> YoutubeDL:
|
def yandex() -> YoutubeDL:
|
||||||
return YoutubeDL()
|
return YoutubeDL()
|
||||||
|
@ -35,13 +45,14 @@ class _CreateYDL:
|
||||||
create_ydl_fn = {
|
create_ydl_fn = {
|
||||||
'youtube': _CreateYDL.youtube,
|
'youtube': _CreateYDL.youtube,
|
||||||
'yt_proxied': _CreateYDL.yt_proxied,
|
'yt_proxied': _CreateYDL.yt_proxied,
|
||||||
|
'soundcloud': _CreateYDL.soundcloud,
|
||||||
'yandex': _CreateYDL.yandex,
|
'yandex': _CreateYDL.yandex,
|
||||||
}
|
}
|
||||||
|
|
||||||
ydl_fn_keys = create_ydl_fn.keys()
|
ydl_fn_keys = create_ydl_fn.keys()
|
||||||
|
|
||||||
# need process=True for track title in extract_info output
|
# need process=True for track title in extract_info output
|
||||||
NP_YDLS = {'yandex'}
|
NP_YDLS = {'yandex', 'soundcloud'}
|
||||||
|
|
||||||
|
|
||||||
class YdlLogger:
|
class YdlLogger:
|
||||||
|
@ -73,9 +84,8 @@ class Downloader:
|
||||||
def __init__(self, logger: YdlLogger | None = None) -> None:
|
def __init__(self, logger: YdlLogger | None = None) -> None:
|
||||||
|
|
||||||
self.ydls: dict[str, YoutubeDL | None] = {
|
self.ydls: dict[str, YoutubeDL | None] = {
|
||||||
'youtube': None,
|
key: None
|
||||||
'yt_proxied': None,
|
for key in ydl_fn_keys
|
||||||
'yandex': None,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.cur_ydl: YoutubeDL | None = None
|
self.cur_ydl: YoutubeDL | None = None
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
<select id="site-select">
|
<select id="site-select">
|
||||||
<option value="youtube" selected>YouTube</option>
|
<option value="youtube" selected>YouTube</option>
|
||||||
<option value="yt_proxied">YT proxied</option>
|
<option value="yt_proxied">YT proxied</option>
|
||||||
|
<option value="soundcloud">SoundCloud</option>
|
||||||
<option value="yandex">Yandex Music</option>
|
<option value="yandex">Yandex Music</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue