45 lines
1.5 KiB
Python
Raw Permalink Normal View History

2022-03-17 18:39:30 +05:30
#!/usr/bin/env python3
2022-01-14 03:10:56 +05:30
import subprocess
import os
import sys
2022-01-09 04:19:22 +05:30
2022-02-17 21:33:33 +05:30
def downloadVideo(search_query,search_query_range):
2022-01-14 03:10:56 +05:30
# animdl download "demon slayer" -r 1
2022-02-17 21:33:33 +05:30
print('animdl', 'download',search_query,f'-r {str(search_query_range)}','--auto')
subprocess.run(['animdl', 'download',search_query,f'-r {str(search_query_range)}','--auto'])
2022-01-14 03:10:56 +05:30
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])
2022-01-15 19:56:53 +05:30
2022-01-14 03:10:56 +05:30
def main(argv):
search_query = argv[1]
2022-02-17 21:33:33 +05:30
print(search_query)
2022-01-14 03:10:56 +05:30
search_query_range = argv[2]
2022-02-17 21:33:33 +05:30
#anime_quality = argv[3] if len(sys.argv) >= 4 else '720[subtitle]'
search_query_in_quotes = f'"{search_query}"'
downloadVideo(search_query_in_quotes,search_query_range)
try:
infile, outfile = getalltsfiles()
except:
infile, outfile = None,None
2022-01-14 03:10:56 +05:30
convert2mp4(infile,outfile)
os.remove(infile)
main(sys.argv[0:])