Replace function make_playlist with a more concise generator expression to improve code readability.

All tests and code format checker are passing
        modified:   yt_dlp/extractor/googledrive.py
This commit is contained in:
grqx_wsl 2024-07-24 23:16:44 +12:00
parent cbe698b4b0
commit 9962859595

View file

@ -345,14 +345,6 @@ def item_url_getter(item, video_id):
self.to_screen(f'Failed to find a suitable extractor for {item[2]}.')
return None
def make_playlist(items, playlist_id):
entries = []
for item in items:
entry = item_url_getter(item, playlist_id)
if entry:
entries.append(entry)
return self.playlist_result(entries, playlist_id, title)
folder_id = self._match_id(url)
headers = self.geo_verification_headers()
@ -365,9 +357,12 @@ def make_playlist(items, playlist_id):
self._extract_json_ds(4, webpage, folder_id, default=None)
or self._extract_json_hash(6, webpage, folder_id)
)
title = json_folder_info[1][2]
items = json_items[-1]
if not isinstance(items, list):
return self.playlist_result([], folder_id, title)
return make_playlist(items, folder_id)
return self.playlist_result(
(entry for item in items if (entry := item_url_getter(item, folder_id))),
folder_id, title)