Mercurial > codedump
comparison channeldownloader.py @ 60:4e7a9c7c0cce
[channeldownloader] Use yt-dlp in place of youtube-dl
committer: GitHub <noreply@github.com>
| author | Paper <37962225+mrpapersonic@users.noreply.github.com> |
|---|---|
| date | Fri, 19 Nov 2021 08:47:32 -0500 |
| parents | a3927b2ec6e6 |
| children | c615532e6572 |
comparison
equal
deleted
inserted
replaced
| 59:a3927b2ec6e6 | 60:4e7a9c7c0cce |
|---|---|
| 2 import internetarchive # pip install internetarchive | 2 import internetarchive # pip install internetarchive |
| 3 import json | 3 import json |
| 4 import os | 4 import os |
| 5 import re | 5 import re |
| 6 import urllib.request | 6 import urllib.request |
| 7 import youtube_dl # pip install youtube-dl | 7 import yt_dlp # pip install yt-dlp |
| 8 import itertools | 8 import itertools |
| 9 from urllib.error import HTTPError | 9 from urllib.error import HTTPError |
| 10 | 10 |
| 11 class MyLogger(object): | 11 class MyLogger(object): |
| 12 def debug(self, msg): | 12 def debug(self, msg): |
| 132 if file.find("-" + i["id"] + ".info.json") != -1: | 132 if file.find("-" + i["id"] + ".info.json") != -1: |
| 133 isalreadydownloaded = 1 | 133 isalreadydownloaded = 1 |
| 134 if isalreadydownloaded == 1: # not sure how to bypass this without having to go out of the for loop, if anyone could tell me how that would be great! | 134 if isalreadydownloaded == 1: # not sure how to bypass this without having to go out of the for loop, if anyone could tell me how that would be great! |
| 135 print(" video already downloaded!") | 135 print(" video already downloaded!") |
| 136 continue | 136 continue |
| 137 with youtube_dl.YoutubeDL(ytdl_opts) as ytdl: | 137 with yt_dlp.YoutubeDL(ytdl_opts) as ytdl: |
| 138 try: | 138 try: |
| 139 result = ytdl.download(["https://youtube.com/watch?v={0}".format(i["id"])]) # TODO: add check for existing downloaded items and don't download them | 139 result = ytdl.download(["https://youtube.com/watch?v={0}".format(i["id"])]) # TODO: add check for existing downloaded items and don't download them |
| 140 continue | 140 continue |
| 141 except Exception: | 141 except Exception: |
| 142 print(" video is not available! attempting to find Internet Archive pages of it...") | 142 print(" video is not available! attempting to find Internet Archive pages of it...") |
