File tree 2 files changed +11
-5
lines changed 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change 82
82
get_videos_json ,
83
83
save_channel_branding ,
84
84
skip_deleted_videos ,
85
+ skip_non_public_videos ,
85
86
skip_outofrange_videos ,
86
87
)
87
88
@@ -611,6 +612,7 @@ def extract_videos_list(self):
611
612
)
612
613
filter_videos = filter (skip_outofrange , videos_json )
613
614
filter_videos = filter (skip_deleted_videos , filter_videos )
615
+ filter_videos = filter (skip_non_public_videos , filter_videos )
614
616
all_videos .update (
615
617
{v ["contentDetails" ]["videoId" ]: v for v in filter_videos }
616
618
)
@@ -1034,10 +1036,9 @@ def update_metadata(self):
1034
1036
def make_json_files (self , actual_videos_ids ):
1035
1037
"""Generate JSON files to be consumed by the frontend"""
1036
1038
1037
- def remove_unused_videos (videos ):
1038
- video_ids = [video ["contentDetails" ]["videoId" ] for video in videos ]
1039
+ def remove_unused_videos ():
1039
1040
for path in self .videos_dir .iterdir ():
1040
- if path .is_dir () and path .name not in video_ids :
1041
+ if path .is_dir () and path .name not in actual_videos_ids :
1041
1042
logger .debug (f"Removing unused video { path .name } " )
1042
1043
shutil .rmtree (path , ignore_errors = True )
1043
1044
@@ -1278,7 +1279,7 @@ def get_playlist_slug(playlist) -> str:
1278
1279
)
1279
1280
1280
1281
# clean videos left out in videos directory
1281
- remove_unused_videos (videos )
1282
+ remove_unused_videos ()
1282
1283
1283
1284
def add_file_to_zim (
1284
1285
self ,
Original file line number Diff line number Diff line change @@ -190,7 +190,7 @@ def get_videos_json(playlist_id):
190
190
PLAYLIST_ITEMS_API ,
191
191
params = {
192
192
"playlistId" : playlist_id ,
193
- "part" : "snippet,contentDetails" ,
193
+ "part" : "snippet,contentDetails,status " ,
194
194
"key" : YOUTUBE .api_key ,
195
195
"maxResults" : RESULTS_PER_PAGE ,
196
196
"pageToken" : page_token ,
@@ -309,6 +309,11 @@ def skip_deleted_videos(item):
309
309
)
310
310
311
311
312
+ def skip_non_public_videos (item ):
313
+ """filter func to filter-out non-public videos"""
314
+ return item ["status" ]["privacyStatus" ] == "public"
315
+
316
+
312
317
def skip_outofrange_videos (date_range , item ):
313
318
"""filter func to filter-out videos that are not within specified date range"""
314
319
return dt_parser .parse (item ["snippet" ]["publishedAt" ]).date () in date_range
You can’t perform that action at this time.
0 commit comments