Spaces:
Runtime error
Runtime error
thejagstudio
commited on
Commit
•
21a0836
1
Parent(s):
503e21c
Update home/views.py
Browse files- home/views.py +26 -0
home/views.py
CHANGED
@@ -32,6 +32,32 @@ def GoogleDriveUpload(filename, folder, file):
|
|
32 |
file1.content = file
|
33 |
file1.Upload()
|
34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
@csrf_exempt
|
37 |
def index(request):
|
|
|
32 |
file1.content = file
|
33 |
file1.Upload()
|
34 |
|
35 |
+
def torrentDownloader(link):
|
36 |
+
import asyncio
|
37 |
+
from torrentp import TorrentDownloader
|
38 |
+
print('Downloading torrent file from link: ', link)
|
39 |
+
torrent_file = TorrentDownloader(link, '/tmp/')
|
40 |
+
# Start the download process
|
41 |
+
asyncio.run(torrent_file.start_download())
|
42 |
+
print('Downloaded torrent file from link: ', link)
|
43 |
+
with open('/tmp/'+torrent_file.file_name, 'rb') as f:
|
44 |
+
file = f.read()
|
45 |
+
file1 = DRIVE.CreateFile({'title': torrent_file.file_name, 'parents': [{'id': '1l6oqVFu-Ys025p7PKjIY0Nwgdr08MwlB'}]})
|
46 |
+
file1.content = file
|
47 |
+
file1.Upload()
|
48 |
+
print('Uploaded torrent file to drive from link: ', torrent_file.file_name)
|
49 |
+
|
50 |
+
|
51 |
+
@csrf_exempt
|
52 |
+
def movieDownloader(request):
|
53 |
+
if request.method == 'POST':
|
54 |
+
data = json.loads(request.body)
|
55 |
+
movie = data['movie']
|
56 |
+
tmdbId = data['tmdbId']
|
57 |
+
torrentLink = data['torrentLink']
|
58 |
+
t1 = threading.Thread(target=torrentDownloader, args=(torrentLink,))
|
59 |
+
t1.start()
|
60 |
+
return HttpResponse(json.dumps({'status': 'success'}), content_type='application/json')
|
61 |
|
62 |
@csrf_exempt
|
63 |
def index(request):
|