aboutsummaryrefslogtreecommitdiffstats
path: root/src/youload_cli.py
blob: 7429b486e7bc5ad371eb41a0dbeba53a35837cd8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from youload_playlist import YouLoadPlayList
import sys

def main() -> None:
    if len(sys.argv) <= 1:
        print("Needs the url")
        return

    # Get playlist
    try:
        playlist = YouLoadPlayList(sys.argv[1])
    except KeyError:
        print("Error getting playlist")
        return

    playlist.prepare_for_download()

    # Download each video.
    for i in range(playlist.video_count):
        print(f"Downloading {i+1}/{playlist.video_count}")
        print(playlist.download_video(i) + "\n")

    print("Download complete")


if __name__ == "__main__":
    main()