- Also fixed copying of netrc file in the container

Signed-off-by: lzzy12 <jhashivam2020@gmail.com>
This commit is contained in:
lzzy12 2020-04-15 13:54:24 +05:30
parent e0f4c4347c
commit c6b4c542b7
5 changed files with 28 additions and 13 deletions

View File

@ -2,17 +2,18 @@ FROM ubuntu:18.04
WORKDIR /usr/src/app WORKDIR /usr/src/app
RUN chmod 777 /usr/src/app RUN chmod 777 /usr/src/app
RUN apt -qq update RUN apt-get -qq update
RUN apt -qq install -y aria2 python3 python3-pip \ RUN apt-get -qq install -y aria2 python3 python3-pip \
locales python3-lxml \ locales python3-lxml \
curl pv jq ffmpeg curl pv jq ffmpeg
COPY requirements.txt . COPY requirements.txt .
RUN pip3 install --no-cache-dir -r requirements.txt RUN pip3 install --no-cache-dir -r requirements.txt
COPY . .
RUN chmod +x aria.sh
RUN locale-gen en_US.UTF-8 RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8 ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8 ENV LC_ALL en_US.UTF-8
COPY . .
COPY netrc /root/.netrc
RUN chmod +x aria.sh
CMD ["bash","start.sh"] CMD ["bash","start.sh"]

View File

@ -119,3 +119,10 @@ python3 gen_sa_accounts.py --download-keys project_id
``` ```
python3 add_to_team_drive.py -d SharedTeamDriveSrcID python3 add_to_team_drive.py -d SharedTeamDriveSrcID
``` ```
# Youtube-dl authentication using .netrc file
For using your premium accounts in youtube-dl, edit the netrc file (in the root directory of this repository) according to following format:
```
machine host login username password my_youtube_password
```
where host is the name of extractor (eg. youtube, twitch). Multiple accounts of different hosts can be added each separated by a new line

View File

@ -21,12 +21,13 @@ class MyLogger:
if match and not self.obj.is_playlist: if match and not self.obj.is_playlist:
self.obj.name = match.group(1) self.obj.name = match.group(1)
def warning(self, msg): @staticmethod
def warning(msg):
LOGGER.warning(msg) LOGGER.warning(msg)
def error(self, msg): @staticmethod
def error(msg):
LOGGER.error(msg) LOGGER.error(msg)
#self.obj.onDownloadError(msg)
class YoutubeDLHelper(DownloadHelper): class YoutubeDLHelper(DownloadHelper):
@ -38,8 +39,9 @@ class YoutubeDLHelper(DownloadHelper):
self.__gid = "" self.__gid = ""
self.opts = { self.opts = {
'progress_hooks': [self.__onDownloadProgress], 'progress_hooks': [self.__onDownloadProgress],
'logger': MyLogger(self),
'usenetrc': True, 'usenetrc': True,
'format': "best" 'format': "best/bestvideo+bestaudio"
} }
self.__download_speed = 0 self.__download_speed = 0
self.download_speed_readable = '' self.download_speed_readable = ''
@ -98,8 +100,12 @@ class YoutubeDLHelper(DownloadHelper):
self.opts['geo_bypass_country'] = 'IN' self.opts['geo_bypass_country'] = 'IN'
with YoutubeDL(self.opts) as ydl: with YoutubeDL(self.opts) as ydl:
result = ydl.extract_info(link, download=False) try:
name = ydl.prepare_filename(result) result = ydl.extract_info(link, download=False)
name = ydl.prepare_filename(result)
except DownloadError as e:
self.onDownloadError(str(e))
return
if result.get('direct'): if result.get('direct'):
return None return None
if 'entries' in result: if 'entries' in result:
@ -133,9 +139,9 @@ class YoutubeDLHelper(DownloadHelper):
self.onDownloadError("Download Cancelled by User!") self.onDownloadError("Download Cancelled by User!")
def add_download(self, link, path): def add_download(self, link, path):
self.extractMetaData(link)
LOGGER.info(f"Downloading with YT-DL: {link}") LOGGER.info(f"Downloading with YT-DL: {link}")
self.__gid = f"{self.vid_id}{self.__listener.uid}" self.__gid = f"{self.vid_id}{self.__listener.uid}"
self.opts['logger'] = MyLogger(self)
if not self.is_playlist: if not self.is_playlist:
self.opts['outtmpl'] = f"{path}/{self.name}" self.opts['outtmpl'] = f"{path}/{self.name}"
else: else:

View File

@ -1,8 +1,8 @@
from telegram.ext import CommandHandler, run_async from telegram.ext import CommandHandler, run_async
from telegram import Bot, Update from telegram import Bot, Update
from bot import Interval, INDEX_URL, DOWNLOAD_DIR, DOWNLOAD_STATUS_UPDATE_INTERVAL, dispatcher, LOGGER from bot import Interval, DOWNLOAD_DIR, DOWNLOAD_STATUS_UPDATE_INTERVAL, dispatcher, LOGGER
from bot.helper.ext_utils.bot_utils import setInterval from bot.helper.ext_utils.bot_utils import setInterval
from bot.helper.telegram_helper.message_utils import update_all_messages, sendMessage from bot.helper.telegram_helper.message_utils import update_all_messages, sendMessage, sendStatusMessage
from .mirror import MirrorListener from .mirror import MirrorListener
from bot.helper.mirror_utils.download_utils.youtube_dl_download_helper import YoutubeDLHelper from bot.helper.mirror_utils.download_utils.youtube_dl_download_helper import YoutubeDLHelper
from bot.helper.telegram_helper.bot_commands import BotCommands from bot.helper.telegram_helper.bot_commands import BotCommands
@ -24,6 +24,7 @@ def _watch(bot: Bot, update: Update, args: list, isTar=False):
listener = MirrorListener(bot, update, isTar, tag) listener = MirrorListener(bot, update, isTar, tag)
ydl = YoutubeDLHelper(listener) ydl = YoutubeDLHelper(listener)
ydl.add_download(link, f'{DOWNLOAD_DIR}{listener.uid}') ydl.add_download(link, f'{DOWNLOAD_DIR}{listener.uid}')
sendStatusMessage(update, bot)
if len(Interval) == 0: if len(Interval) == 0:
Interval.append(setInterval(DOWNLOAD_STATUS_UPDATE_INTERVAL, update_all_messages)) Interval.append(setInterval(DOWNLOAD_STATUS_UPDATE_INTERVAL, update_all_messages))

0
netrc Normal file
View File