add ignore downloads flag

This commit is contained in:
Cyberes 2023-02-01 13:06:11 -07:00
parent 2b52231810
commit 915d7f89f0
1 changed files with 9 additions and 7 deletions

View File

@ -37,6 +37,7 @@ parser.add_argument('--threads', type=int, default=cpu_count(), help='How many d
parser.add_argument('--daemon', '-d', action='store_true', help="Run in daemon mode. Disables progress bars sleeps for the amount of time specified in --sleep.") parser.add_argument('--daemon', '-d', action='store_true', help="Run in daemon mode. Disables progress bars sleeps for the amount of time specified in --sleep.")
parser.add_argument('--sleep', type=float, default=60, help='How many minutes to sleep when in daemon mode.') parser.add_argument('--sleep', type=float, default=60, help='How many minutes to sleep when in daemon mode.')
parser.add_argument('--silence-errors', '-s', action='store_true', help="Don't print any error messages to the console.") parser.add_argument('--silence-errors', '-s', action='store_true', help="Don't print any error messages to the console.")
parser.add_argument('--ignore-downloaded', '-i', action='store_true', help='Ignore videos that have been already downloaded and let YouTubeDL handle everything.')
args = parser.parse_args() args = parser.parse_args()
if args.threads <= 0: if args.threads <= 0:
@ -225,13 +226,14 @@ while True:
# sys.exit() # sys.exit()
# Remove already downloaded files from the to-do list. # Remove already downloaded files from the to-do list.
download_queue = [] if not args.ignore_downloaded:
s = set() download_queue = []
for p, video in enumerate(playlist['entries']): s = set()
if video['id'] not in downloaded_videos and video['id'] not in s: for p, video in enumerate(playlist['entries']):
download_queue.append(video) if video['id'] not in downloaded_videos and video['id'] not in s:
s.add(video['id']) download_queue.append(video)
playlist_bar.update(len(downloaded_videos)) s.add(video['id'])
playlist_bar.update(len(downloaded_videos))
if len(download_queue): # Don't mess with multiprocessing if all videos are already downloaded if len(download_queue): # Don't mess with multiprocessing if all videos are already downloaded
with Pool(processes=args.threads) as pool: with Pool(processes=args.threads) as pool: