mirror of
https://github.com/meeb/tubesync.git
synced 2025-06-23 21:46:44 +00:00
Add get_channel_id
This commit is contained in:
parent
ba321945b6
commit
e5b4e9dbc0
@ -45,6 +45,31 @@ def get_yt_opts():
|
||||
opts.update({'cookiefile': cookie_file_path})
|
||||
return opts
|
||||
|
||||
def get_channel_id(url):
|
||||
# yt-dlp --simulate --no-check-formats --playlist-items 1
|
||||
# --print 'pre_process:%(playlist_channel_id,playlist_id,channel_id)s'
|
||||
opts = get_yt_opts()
|
||||
opts.update({
|
||||
'skip_download': True,
|
||||
'simulate': True,
|
||||
'logger': log,
|
||||
'extract_flat': True, # Change to False to get detailed info
|
||||
'check_formats': False,
|
||||
'playlist_items': '1',
|
||||
})
|
||||
|
||||
with yt_dlp.YoutubeDL(opts) as y:
|
||||
try:
|
||||
response = y.extract_info(url, download=False)
|
||||
|
||||
channel_id = response['channel_id']
|
||||
playlist_id = response['playlist_id']
|
||||
playlist_channel_id = response['playlist_channel_id']
|
||||
except yt_dlp.utils.DownloadError as e:
|
||||
raise YouTubeError(f'Failed to extract channel ID for "{url}": {e}') from e
|
||||
else:
|
||||
return playlist_channel_id or playlist_id or channel_id
|
||||
|
||||
def get_channel_image_info(url):
|
||||
opts = get_yt_opts()
|
||||
opts.update({
|
||||
|
Loading…
Reference in New Issue
Block a user