From c7938d144fe9aae1d3a8064f74785f8e00c80c25 Mon Sep 17 00:00:00 2001 From: Ara0n Date: Fri, 14 Jan 2022 03:10:56 +0530 Subject: [PATCH] added updateded on downloaderService --- Pipfile | 5 +++-- downloaderService/main.py | 41 ++++++++++++++++++++++++++++++++++++--- requirments.txt | 33 ++++++++++++++++--------------- 3 files changed, 58 insertions(+), 21 deletions(-) diff --git a/Pipfile b/Pipfile index b987ecb..b9ba467 100644 --- a/Pipfile +++ b/Pipfile @@ -8,8 +8,6 @@ verify_ssl = true [packages] python-telegram-bot = "==13.10" telegramclient = "*" -telethon = "==1.24.0" -backports-zoneinfo = "==0.2.1" cachetools = "==4.2.2" certifi = "==2021.10.8" pyaes = "==1.6.1" @@ -22,6 +20,9 @@ tornado = "==6.1" tzdata = "==2021.5" tzlocal = "==4.1" APScheduler = "==3.6.3" +ffmpeg = "*" +Telethon = "==1.24.0" +"backports.zoneinfo" = "==0.2.1" [requires] python_version = "3.8" diff --git a/downloaderService/main.py b/downloaderService/main.py index 10cea81..c7214ad 100644 --- a/downloaderService/main.py +++ b/downloaderService/main.py @@ -1,4 +1,39 @@ -from animdl import * +import subprocess +import os -def downloadVideo(): - pass +def downloadVideo(search_query,search_query_range,search_quality): + # animdl download "demon slayer" -r 1 + subprocess.run(['animdl', 'download',search_query,f'-r {str(search_query_range)}','--auto','-q',search_quality]) + +def getalltsfiles(): + walk_dir = os.getcwd() + for root, _, files in os.walk(walk_dir): + for file in files: + if (file.split(".")[-1].lower() == 'ts'): + filePath = os.path.join(root, file) + mp4FilePath = os.path.join(root, os.path.splitext(file)[0] + ".mp4") + if os.path.isfile(mp4FilePath): + continue + return filePath, mp4FilePath + + +def convert2mp4(infile, outfile): + + # ffmpeg -i E01.ts -c:v copy -c:a copy -preset:v ultrafast -segment_list_flags +live video.mp4 + + subprocess.run(['ffmpeg','-i',infile,'-c:v','copy','-c:a','copy','-preset:v','ultrafast','-segment_list_flags','+live',outfile]) + +def main(argv): + + search_query = argv[1] + search_query_range = argv[2] + anime_quality = argv[3] if len(sys.argv) >= 4 else '720[subtitle]' + + downloadVideo(search_query,search_query_range,anime_quality) + infile, outfile = getalltsfiles() + convert2mp4(infile,outfile) + os.remove(infile) + +if __name__ == '__main__': + import sys + main(sys.argv[0:]) \ No newline at end of file diff --git a/requirments.txt b/requirments.txt index b93f13e..f5ee54f 100644 --- a/requirments.txt +++ b/requirments.txt @@ -1,16 +1,17 @@ -APScheduler==3.6.3 -backports.zoneinfo==0.2.1 -cachetools==4.2.2 -certifi==2021.10.8 -pyaes==1.6.1 -pyasn1==0.4.8 -python-telegram-bot==13.10 -pytz==2021.3 -pytz-deprecation-shim==0.1.0.post0 -rsa==4.8 -six==1.16.0 -Telethon==1.24.0 -tornado==6.1 -tzdata==2021.5 -tzlocal==4.1 -telethon==1.24.0 \ No newline at end of file +python-telegram-bot=="13.10" +telegramclient=="*" +cachetools=="4.2.2" +certifi=="2021.10.8" +pyaes=="1.6.1" +pyasn1=="0.4.8" +pytz=="2021.3" +pytz-deprecation-shim=="0.1.0.post0" +rsa=="4.8" +six=="1.16.0" +tornado=="6.1" +tzdata=="2021.5" +tzlocal=="4.1" +APScheduler=="3.6.3" +ffmpeg = "*" +Telethon=="1.24.0" +"backports.zoneinfo"=="0.2.1" \ No newline at end of file