[BACKEND] Handle case when collection url is missing from entry (#558)

* [BACKEND] Handle case when collection url is missing from entry

* hide experimental docs
This commit is contained in:
Jesse Bannon 2023-03-21 13:39:41 -07:00 committed by GitHub
parent 7385aac1ee
commit 54b8b76034
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 6 deletions

View file

@ -29,7 +29,7 @@ and subscriptions.
.. autoclass:: ytdl_sub.config.config_validator.ConfigOptions() .. autoclass:: ytdl_sub.config.config_validator.ConfigOptions()
:members: :members:
:member-order: bysource :member-order: bysource
:exclude-members: persist_logs :exclude-members: persist_logs, experimental
persist_logs persist_logs
"""""""""""" """"""""""""

View file

@ -175,7 +175,7 @@ class UrlDownloaderThumbnailPlugin(BaseDownloaderPlugin):
""" """
Use the entry to download thumbnails (or move if LATEST_ENTRY) Use the entry to download thumbnails (or move if LATEST_ENTRY)
""" """
if entry.kwargs(COLLECTION_URL) in self._collection_url_mapping: if entry.kwargs_get(COLLECTION_URL) in self._collection_url_mapping:
self._download_url_thumbnails( self._download_url_thumbnails(
collection_url=self._collection_url_mapping[entry.kwargs(COLLECTION_URL)], collection_url=self._collection_url_mapping[entry.kwargs(COLLECTION_URL)],
entry=entry, entry=entry,
@ -205,11 +205,17 @@ class UrlDownloaderCollectionVariablePlugin(BaseDownloaderPlugin):
""" """
Add collection variables to the entry Add collection variables to the entry
""" """
collection_url: Optional[UrlValidator] = self._collection_url_mapping.get( # COLLECTION_URL is a recent variable that may not exist for old entries when updating.
entry.kwargs(COLLECTION_URL) # Try to use source_webpage_url if it does not exist
entry_collection_url = entry.kwargs_get(COLLECTION_URL, entry.source_webpage_url)
# If the collection URL cannot find its mapping, use the last URL
collection_url = (
self._collection_url_mapping.get(entry_collection_url)
or list(self._collection_url_mapping.values())[-1]
) )
if collection_url:
entry.add_variables(variables_to_add=collection_url.variables.dict_with_format_strings) entry.add_variables(variables_to_add=collection_url.variables.dict_with_format_strings)
return entry return entry