Replace youtube-dl with yt-dlp and update Dockerfle (#101)
This commit is contained in:
1 parent
016c551923
commit
faceff7206
6 files changed
+34
-74
No files matched your search
+13
-52
@@ -1,57 +1,18 @@
|
||||
FROM ubuntu
|
||||
FROM python:3.9-alpine3.14
|
||||
|
||||
VOLUME /opt
|
||||
RUN export DEBIAN_FRONTEND=noninteractive \
|
||||
&& apt-get update \
|
||||
&& apt install curl -y \
|
||||
&& apt install ffmpeg -y \
|
||||
&& apt install -y python3-pip \
|
||||
&& apt-get install -y git \
|
||||
&& apt-get install -y zip \
|
||||
&& pip install quickjs \
|
||||
# && apt-get install -y unzip \
|
||||
&& \
|
||||
DL=https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
|
||||
&& curl -sL "$DL" > /tmp/chrome.deb \
|
||||
&& apt install --no-install-recommends --no-install-suggests -y \
|
||||
/tmp/chrome.deb \
|
||||
&& CHROMIUM_FLAGS='--no-sandbox --disable-dev-shm-usage' \
|
||||
# Patch Chrome launch script and append CHROMIUM_FLAGS to the last line:
|
||||
&& sed -i '${s/$/'" $CHROMIUM_FLAGS"'/}' /opt/google/chrome/google-chrome \
|
||||
&& BASE_URL=https://chromedriver.storage.googleapis.com \
|
||||
&& VERSION=$(curl -sL "$BASE_URL/LATEST_RELEASE") \
|
||||
&& curl -sL "$BASE_URL/$VERSION/chromedriver_linux64.zip" -o /tmp/driver.zip \
|
||||
&& unzip /tmp/driver.zip \
|
||||
&& chmod 755 chromedriver \
|
||||
&& mv chromedriver /usr/local/bin/ \
|
||||
&& apt-get install -y locales \
|
||||
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 \
|
||||
# Remove obsolete files:
|
||||
&& apt-get autoremove --purge -y \
|
||||
unzip \
|
||||
&& apt-get clean \
|
||||
&& rm -rf \
|
||||
/tmp/* \
|
||||
/usr/share/doc/* \
|
||||
/var/cache/* \
|
||||
/var/lib/apt/lists/* \
|
||||
/var/tmp/*
|
||||
|
||||
ENV LANG en_US.utf8
|
||||
|
||||
#COPY requirements.txt /opt/
|
||||
#RUN cd /opt \
|
||||
# && pip3 install -r requirements.txt
|
||||
#USER webdriver
|
||||
RUN pip3 install git+https://github.com/ForgQi/bilibiliupload.git
|
||||
|
||||
#COPY common /opt/common
|
||||
#COPY engine /opt/engine
|
||||
#COPY Bilibili.py /opt/
|
||||
#RUN chmod 755 /opt/Bilibili.py
|
||||
COPY ["config(demo).yaml", "/opt/config.yaml"]
|
||||
RUN \
|
||||
set -eux && \
|
||||
apk update && \
|
||||
apk add --no-cache --virtual .build-deps git curl gcc g++ && \
|
||||
apk add --no-cache ffmpeg musl-dev libffi-dev zlib-dev jpeg-dev ca-certificates && \
|
||||
git clone --depth 1 https://github.com/ForgQi/biliup.git && \
|
||||
cd biliup && \
|
||||
pip3 install --no-cache-dir -r requirements.txt && \
|
||||
pip3 install -e . && \
|
||||
apk del .build-deps
|
||||
|
||||
WORKDIR /opt
|
||||
#ENTRYPOINT ["./Bilibili.py"]
|
||||
ENTRYPOINT ["biliup"]
|
||||
|
||||
#EXPOSE 9515/tcp
|
||||
ENTRYPOINT ["biliup"]
|
||||
@@ -1,7 +1,7 @@
|
||||
from threading import Event
|
||||
|
||||
import streamlink
|
||||
import youtube_dl
|
||||
import yt_dlp
|
||||
from ykdl.common import url_to_module
|
||||
|
||||
from ..engine.download import DownloadBase
|
||||
@@ -17,13 +17,13 @@ class YDownload(DownloadBase):
|
||||
try:
|
||||
self.get_sinfo()
|
||||
return True
|
||||
except youtube_dl.utils.DownloadError:
|
||||
except yt_dlp.utils.DownloadError:
|
||||
logger.debug('%s未开播或读取下载信息失败' % self.fname)
|
||||
return False
|
||||
|
||||
def get_sinfo(self):
|
||||
info_list = []
|
||||
with youtube_dl.YoutubeDL() as ydl:
|
||||
with yt_dlp.YoutubeDL() as ydl:
|
||||
if self.url:
|
||||
info = ydl.extract_info(self.url, download=False)
|
||||
else:
|
||||
@@ -37,9 +37,9 @@ class YDownload(DownloadBase):
|
||||
def download(self, filename):
|
||||
try:
|
||||
self.ydl_opts = {'outtmpl': filename}
|
||||
with youtube_dl.YoutubeDL(self.ydl_opts) as ydl:
|
||||
with yt_dlp.YoutubeDL(self.ydl_opts) as ydl:
|
||||
ydl.download([self.url])
|
||||
except youtube_dl.utils.DownloadError:
|
||||
except yt_dlp.utils.DownloadError:
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import time
|
||||
from urllib.parse import urlencode
|
||||
|
||||
import requests
|
||||
import youtube_dl
|
||||
import yt_dlp
|
||||
|
||||
from ..engine.decorators import Plugin
|
||||
from ..plugins import BatchCheckBase, match1
|
||||
@@ -30,7 +30,7 @@ class TwitchVideos(DownloadBase):
|
||||
DownloadBase.__init__(self, fname, url, suffix=suffix)
|
||||
|
||||
def check_stream(self):
|
||||
with youtube_dl.YoutubeDL({'download_archive': 'archive.txt'}) as ydl:
|
||||
with yt_dlp.YoutubeDL({'download_archive': 'archive.txt'}) as ydl:
|
||||
info = ydl.extract_info(self.url, download=False)
|
||||
for entry in info['entries']:
|
||||
if ydl.in_download_archive(entry):
|
||||
@@ -45,7 +45,7 @@ class TwitchVideos(DownloadBase):
|
||||
BatchCheckBase.__init__(self, pattern_id=VALID_URL_BASE, urls=urls)
|
||||
|
||||
def check(self):
|
||||
with youtube_dl.YoutubeDL({'download_archive': 'archive.txt'}) as ydl:
|
||||
with yt_dlp.YoutubeDL({'download_archive': 'archive.txt'}) as ydl:
|
||||
for channel_name, url in self.not_live():
|
||||
info = ydl.extract_info(url, download=False, process=False)
|
||||
for entry in info['entries']:
|
||||
@@ -108,10 +108,10 @@ class Twitch(DownloadBase):
|
||||
time.sleep(1)
|
||||
i += 1
|
||||
return True
|
||||
# with youtube_dl.YoutubeDL() as ydl:
|
||||
# with yt_dlp.YoutubeDL() as ydl:
|
||||
# try:
|
||||
# info = ydl.extract_info(self.url, download=False)
|
||||
# except youtube_dl.utils.DownloadError as e:
|
||||
# except yt_dlp.utils.DownloadError as e:
|
||||
# logger.warning(self.url, exc_info=e)
|
||||
# return
|
||||
# self.raw_stream_url = info['formats'][-1]['url']
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
import time
|
||||
|
||||
import youtube_dl
|
||||
from youtube_dl import MaxDownloadsReached
|
||||
import yt_dlp
|
||||
from yt_dlp.utils import MaxDownloadsReached
|
||||
|
||||
from ..engine.decorators import Plugin
|
||||
from ..engine.download import DownloadBase
|
||||
from ..plugins import BatchCheckBase
|
||||
from . import logger
|
||||
|
||||
VALID_URL_BASE = r'https?://(?:(?:www|m)\.)?youtube\.com/(?P<id>.*?)\??(.*?)'
|
||||
@@ -16,7 +13,7 @@ class Youtube(DownloadBase):
|
||||
DownloadBase.__init__(self, fname, url, suffix=suffix)
|
||||
|
||||
def check_stream(self):
|
||||
with youtube_dl.YoutubeDL({'download_archive': 'archive.txt', 'ignoreerrors': True, 'extract_flat': True}) as ydl:
|
||||
with yt_dlp.YoutubeDL({'download_archive': 'archive.txt', 'ignoreerrors': True, 'extract_flat': True}) as ydl:
|
||||
info = ydl.extract_info(self.url, download=False, process=False)
|
||||
if info is None:
|
||||
logger.warning(self.url)
|
||||
@@ -39,11 +36,11 @@ class Youtube(DownloadBase):
|
||||
'max_downloads': 1,
|
||||
'download_archive': 'archive.txt'
|
||||
}
|
||||
with youtube_dl.YoutubeDL(self.ydl_opts) as ydl:
|
||||
with yt_dlp.YoutubeDL(self.ydl_opts) as ydl:
|
||||
ydl.download([self.url])
|
||||
except MaxDownloadsReached:
|
||||
return False
|
||||
except youtube_dl.utils.DownloadError:
|
||||
except yt_dlp.utils.DownloadError:
|
||||
logger.exception(self.fname)
|
||||
return 1
|
||||
return 0
|
||||
+4
-3
@@ -1,10 +1,11 @@
|
||||
selenium>=3.8.1
|
||||
psutil>=5.4.6
|
||||
youtube_dl>=2021.12.17
|
||||
yt_dlp>=2022.3.8.2
|
||||
Pillow>=5.2.0
|
||||
aiohttp[speedups]
|
||||
Requests>=2.20.0
|
||||
PyYAML>=4.2b1
|
||||
streamlink>=0.14.2
|
||||
ykdl >= 1.7.1
|
||||
rsa>=4.6
|
||||
ykdl>=1.7.1
|
||||
rsa>=4.6
|
||||
quickjs>=1.17.0
|
||||
@@ -15,7 +15,7 @@ python_requires = >= 3.7
|
||||
install_requires =
|
||||
selenium >= 3.8.1
|
||||
psutil >= 5.4.6
|
||||
youtube_dl >= 2021.12.17
|
||||
yt_dlp >= 2022.3.8.2
|
||||
Pillow >= 5.2.0
|
||||
aiohttp[speedups]
|
||||
Requests >= 2.20.0
|
||||
@@ -23,6 +23,7 @@ install_requires =
|
||||
streamlink >= 0.14.2
|
||||
ykdl >= 1.7.1
|
||||
rsa >= 4.6
|
||||
quickjs >= 1.17.0
|
||||
|
||||
[options.package_data]
|
||||
biliup = common/*.ini
|
||||
|
||||
Reference in new issue
Block a user