Skip to content

Commit

Permalink
[BUGFIX] Fix YouTube channels iterating 2x entries (#903)
Browse files Browse the repository at this point in the history
A recent feature to grab channel artwork for playlists caused downloading channels to misreport the number of entries it was downloading. This change fixes that
  • Loading branch information
jmbannon authored Jan 19, 2024
1 parent f0b3991 commit 2939886
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/ytdl_sub/downloaders/ytdlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,20 +248,22 @@ def extract_info_via_info_json(
continue

cls.logger.debug("Attempting to get parent metadata from URL %s", uploader_url)
parent_dict: Optional[Dict] = None
try:
parent_dict = cls.extract_info(
ytdl_options_overrides=ytdl_options_overrides | {"playlist_items": "0:0"},
url=uploader_url,
)
except Exception: # pylint: disable=broad-except
# Do not try this uploader_id again
entry_ids.add(uploader_id)
break
pass

if isinstance(parent_dict, dict):
parent_id = parent_dict.get("id")
parent_id = parent_dict.get("id") if isinstance(parent_dict, dict) else None
if parent_id and parent_id not in entry_ids:
parent_dicts.append(parent_dict)
entry_ids |= {uploader_id, parent_id}
entry_ids.add(parent_id)
cls.logger.debug("Adding parent metadata with ids [%s, %s]", uploader_id, parent_id)

# Always add the uploader_id since it has been tried
entry_ids.add(uploader_id)

return entry_dicts + parent_dicts

0 comments on commit 2939886

Please sign in to comment.