openzim / youtube

Create a ZIM file from a Youtube channel/username/playlist
GNU General Public License v3.0
54 stars 30 forks source link

What happens when there is no video in channel / playlist? #347

Closed benoit74 closed 1 month ago

benoit74 commented 2 months ago

From https://github.com/openzim/youtube/pull/341#pullrequestreview-2324996456

What happens when the channel has no video, or the playlist(s) have no video in the end? Do we create an almost empty ZIM?

We need to ensure that scraper fails in such a situation with a clear error message.

dan-niles commented 1 month ago

Since #341 ensures that all empty playlists are ignored, it's better to throw an error if no playlists with videos remain, rather than creating an empty ZIM file.

In the extract_videos_list method, after removing the empty playlists, adding the following two lines should be enough to throw an error:

for playlist in empty_playlists:
    self.playlists.remove(playlist)

# Add these two lines
if not self.playlists:
    raise Exception("No videos found in playlists")

WDYT?

benoit74 commented 1 month ago

I like it!