File tree Expand file tree Collapse file tree 1 file changed +9
-10
lines changed
Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change 11import os
22import tempfile
33import shutil
4+ from threading import Thread
45
56from youtube_dl import YoutubeDL
67from flask import Flask , request
1112VID_PATH = "/mnt/Data/Public/Videos/Other/Youtubes/vids/"
1213TMP_PATH = "/mnt/Data/Public/Videos/Other/Youtubes/downloader/temp"
1314
14- @app .route ("/dlvid" , methods = ["GET" ])
15- def dlvid ():
16- url = request .args .get ('url' )
17-
18- if 'results' in url and 'search_query' in url :
19- # This is a search page
20- return ""
21-
15+ def download (url ):
2216 f = open (os .path .join (original_path , "log.txt" ), "a" )
23-
2417 try :
2518 info_dict = ydl .extract_info (url , download = False )
2619 filename = ydl .prepare_filename (info_dict )
@@ -39,9 +32,15 @@ def dlvid():
3932 f .write ("Downloaded " + url + '\n ' )
4033 except Exception as e :
4134 f .write ("FAILED " + url + ' . because ' + e .message + '\n ' )
42-
4335 f .close ()
4436
37+ @app .route ("/dlvid" , methods = ["GET" ])
38+ def dlvid ():
39+ url = request .args .get ('url' )
40+ if 'results' in url and 'search_query' in url :
41+ # This is a search page
42+ return ""
43+ Thread (target = download , args = (url ,)).start ()
4544 return ""
4645
4746if __name__ == "__main__" :
You can’t perform that action at this time.
0 commit comments