handle deleting channel without videos

This commit is contained in:
simon 2021-10-31 17:30:29 +07:00
parent 164ee5c523
commit 283a72308e

View File

@ -227,11 +227,15 @@ class YoutubeChannel:
print(f"deleting {self.channel_id} and all matching media files") print(f"deleting {self.channel_id} and all matching media files")
folder_path = self.get_folder_path() folder_path = self.get_folder_path()
print("delete all media files") print("delete all media files")
try:
all_videos = os.listdir(folder_path) all_videos = os.listdir(folder_path)
for video in all_videos: for video in all_videos:
video_path = os.path.join(folder_path, video) video_path = os.path.join(folder_path, video)
os.remove(video_path) os.remove(video_path)
os.rmdir(folder_path) os.rmdir(folder_path)
except FileNotFoundError:
print(f"no videos found for {folder_path}")
ThumbManager().delete_chan_thumb(self.channel_id) ThumbManager().delete_chan_thumb(self.channel_id)
print("delete indexed videos") print("delete indexed videos")