Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade youtube dl #417

Merged
merged 2 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .github/workflows/pythontest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,10 @@ jobs:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
python-version: [3.6, 3.7, 3.8, 3.9, '3.10']
exclude:
- os: ubuntu-latest
python-version: 3.6
python-version: [3.7, 3.8, 3.9, '3.10']
include:
- os: ubuntu-latest
pippath: ~/.cache/pip
- os: ubuntu-20.04
python-version: 3.6
pippath: ~/.cache/pip
- os: macos-latest
pippath: ~/Library/Caches/pip
- os: windows-latest
Expand Down
16 changes: 7 additions & 9 deletions ricecooker/classes/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from xml.etree import ElementTree

import filetype
import youtube_dl
import yt_dlp
from cachecontrol.caches.file_cache import FileCache
from le_utils.constants import exercises
from le_utils.constants import file_formats
Expand Down Expand Up @@ -433,16 +433,16 @@ def download_from_web(
# Download the web_url which can be either a video or subtitles
if not config.USEPROXY:
# Connect to YouTube directly
with youtube_dl.YoutubeDL(download_settings) as ydl:
with yt_dlp.YoutubeDL(download_settings) as ydl:
ydl.download([web_url])
if not os.path.exists(destination_path):
raise youtube_dl.utils.DownloadError("Failed to download " + web_url)
raise yt_dlp.utils.DownloadError("Failed to download " + web_url)
else:
# Connect to YouTube via an HTTP proxy
yt_resource = YouTubeResource(web_url, useproxy=True, options=download_settings)
result1 = yt_resource.get_resource_info()
if result1 is None:
raise youtube_dl.utils.DownloadError("Failed to get resource info")
raise yt_dlp.utils.DownloadError("Failed to get resource info")
download_settings["writethumbnail"] = False # overwrite default behaviour
if file_format == file_formats.VTT:
# We need to use the proxy when downloading subtitles
Expand All @@ -451,9 +451,7 @@ def download_from_web(
# For video files we can skip the proxy for faster download speed
result2 = yt_resource.download(options=download_settings)
if result2 is None or not os.path.exists(destination_path):
raise youtube_dl.utils.DownloadError(
"Failed to download resource " + web_url
)
raise yt_dlp.utils.DownloadError("Failed to download resource " + web_url)

# Write file to local storage
filename = copy_file_to_storage(destination_path, ext=file_format)
Expand Down Expand Up @@ -933,7 +931,7 @@ def process_file(self):
extract_path_ext(self.filename),
)

except (youtube_dl.utils.DownloadError, VideoCompressionError) as err:
except (yt_dlp.utils.DownloadError, VideoCompressionError) as err:
self.filename = None
self.error = str(err)
config.FAILED_FILES.append(self)
Expand Down Expand Up @@ -1009,7 +1007,7 @@ def process_file(self):
self.filename = self.download_subtitle()
config.LOGGER.info("\t--- Downloaded subtitle {}".format(self.filename))
return self.filename
except (FileNotFoundError, youtube_dl.utils.DownloadError):
except (FileNotFoundError, yt_dlp.utils.DownloadError):
self.error = str(
"Subtitle with langauge {} is not available for {}".format(
self.language, self.youtube_url
Expand Down
2 changes: 1 addition & 1 deletion ricecooker/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def setup_logging(level=logging.INFO, main_log=None, error_log=None, add_loggers
DOWNLOAD_SESSION = requests.Session()
DOWNLOAD_SESSION.mount("file://", FileAdapter())

# Environment variable indicating we should use a proxy for youtube_dl downloads
# Environment variable indicating we should use a proxy for yt_dlp downloads
USEPROXY = False
USEPROXY = (
True
Expand Down
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
"requests_file",
"beautifulsoup4>=4.6.3,<4.9.0", # pinned to match versions in le-pycaption
"selenium==3.0.1",
"youtube-dl>=2020.6.16.1",
"yt-dlp==2022.03.08.1",
"yt-dlp>=2023.3.4",
"html5lib",
"cachecontrol==0.12.0",
"lockfile==0.12.2", # TODO: check if this is necessary
Expand Down Expand Up @@ -60,17 +59,18 @@
},
include_package_data=True,
install_requires=requirements,
python_requires=">=3.6, <3.11",
python_requires=">=3.7, <3.11",
license="MIT license",
zip_safe=False,
keywords="ricecooker",
classifiers=[
"Intended Audience :: Developers",
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Natural Language :: English",
"Topic :: Education",
],
Expand Down