Adding debugging when finding channel.

This commit is contained in:
Roland 2023-11-24 19:23:25 -07:00
parent cccdd8fe4e
commit 760d949f5e
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
2 changed files with 5 additions and 4 deletions

View file

@ -217,12 +217,14 @@ class VideoDownloader(Downloader, ABC):
source_channel_id = info.get('channel_id')
channel_url = info.get('channel_url')
channel = None
logger.debug(f'{channel_name=} {source_channel_id=} {channel_url=}')
if channel_name or source_channel_id:
# Try to find the channel via info_json from yt-dlp.
try:
channel = get_or_create_channel(source_id=source_channel_id, url=channel_url, name=channel_name)
if channel:
found_channel = 'yt_dlp'
logger.debug(f'Found a channel with source_id {channel=}')
except UnknownChannel:
# Can't find a channel, use the no channel directory.
pass
@ -234,6 +236,7 @@ class VideoDownloader(Downloader, ABC):
try:
channel = get_channel(directory=destination, return_dict=False)
found_channel = 'download_settings_directory'
logger.debug(f'Found a channel that shares the destination directory {channel=}')
except UnknownChannel:
# Destination must not be a channel.
pass
@ -245,6 +248,7 @@ class VideoDownloader(Downloader, ABC):
logger.info(f'Using download.settings to find channel')
try:
channel = get_channel(channel_id=local_channel_id, url=channel_url, return_dict=False)
logger.debug(f'Found channel with channel url {channel=}')
except UnknownChannel:
# We do not need a Channel if we have a destination directory.
if not destination:

View file

@ -24,10 +24,7 @@ def strip_extra_from_url(url: str) -> str:
def normalize_video_url(url: str) -> str:
"""Convert video URLs to what is expected to be in the yt-dlp info json."""
url = url.strip()
if match := YOUTUBE_SHORT_REGEX.match(url):
source_id = match.group(1)
url = f'https://www.youtube.com/watch?v={source_id}'
if match := YOUTU_BE_REGEX.match(url):
if (match := YOUTUBE_SHORT_REGEX.match(url)) or (match := YOUTU_BE_REGEX.match(url)):
source_id = match.group(1)
url = f'https://www.youtube.com/watch?v={source_id}'
url = strip_extra_from_url(url)