Spaces:
Runtime error
Runtime error
thejagstudio
commited on
Update home/views.py
Browse files- home/views.py +20 -25
home/views.py
CHANGED
@@ -6,7 +6,6 @@ from django.contrib.auth.models import User
|
|
6 |
import json
|
7 |
from .models import Userdata, ip_address
|
8 |
import threading
|
9 |
-
from django.core.files.storage import FileSystemStorage
|
10 |
from django.conf import settings
|
11 |
from django.views.decorators.csrf import csrf_exempt, csrf_protect
|
12 |
from django.core.mail import send_mail
|
@@ -28,9 +27,9 @@ else:
|
|
28 |
DRIVE = GoogleDrive(gauth)
|
29 |
|
30 |
|
31 |
-
def GoogleDriveUpload(filename, folder):
|
32 |
file1 = DRIVE.CreateFile({'title': filename, 'parents': [{'id': folder}]})
|
33 |
-
file1.
|
34 |
file1.Upload()
|
35 |
|
36 |
|
@@ -115,17 +114,13 @@ def uploader(request):
|
|
115 |
title = request.POST['title']
|
116 |
if title == '':
|
117 |
title = file.name
|
118 |
-
fs = FileSystemStorage(location=folder)
|
119 |
-
filename = fs.save(title, file)
|
120 |
-
# print(filename)
|
121 |
if file.name == '':
|
122 |
-
return redirect('
|
123 |
folder_id = Userdata.objects.get(user_id=request.user).folder
|
124 |
-
thread = threading.Thread(target=GoogleDriveUpload, args=(title, folder_id))
|
125 |
thread.start()
|
126 |
thread.join()
|
127 |
-
|
128 |
-
return redirect('../upload/')
|
129 |
|
130 |
|
131 |
@csrf_exempt
|
@@ -188,20 +183,20 @@ def renameFile(request):
|
|
188 |
return HttpResponse(json.dumps({'status': 'success'}), content_type='application/json')
|
189 |
|
190 |
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
|
206 |
|
207 |
def ipGetter(request):
|
@@ -210,7 +205,6 @@ def ipGetter(request):
|
|
210 |
if ipIn is None:
|
211 |
new_entry = ip_address(ip=ip)
|
212 |
new_entry.save()
|
213 |
-
print(ip)
|
214 |
return HttpResponse(json.dumps({'status': 'success'}), content_type='application/json')
|
215 |
|
216 |
|
@@ -229,3 +223,4 @@ def godMode(request):
|
|
229 |
my_map1.save('templates/godMode.html')
|
230 |
return render(request, 'godMode.html')
|
231 |
|
|
|
|
6 |
import json
|
7 |
from .models import Userdata, ip_address
|
8 |
import threading
|
|
|
9 |
from django.conf import settings
|
10 |
from django.views.decorators.csrf import csrf_exempt, csrf_protect
|
11 |
from django.core.mail import send_mail
|
|
|
27 |
DRIVE = GoogleDrive(gauth)
|
28 |
|
29 |
|
30 |
+
def GoogleDriveUpload(filename, folder, file):
|
31 |
file1 = DRIVE.CreateFile({'title': filename, 'parents': [{'id': folder}]})
|
32 |
+
file1.content = file
|
33 |
file1.Upload()
|
34 |
|
35 |
|
|
|
114 |
title = request.POST['title']
|
115 |
if title == '':
|
116 |
title = file.name
|
|
|
|
|
|
|
117 |
if file.name == '':
|
118 |
+
return redirect('/upload/')
|
119 |
folder_id = Userdata.objects.get(user_id=request.user).folder
|
120 |
+
thread = threading.Thread(target=GoogleDriveUpload, args=(title, folder_id, file))
|
121 |
thread.start()
|
122 |
thread.join()
|
123 |
+
return redirect('/upload/')
|
|
|
124 |
|
125 |
|
126 |
@csrf_exempt
|
|
|
183 |
return HttpResponse(json.dumps({'status': 'success'}), content_type='application/json')
|
184 |
|
185 |
|
186 |
+
@csrf_exempt
|
187 |
+
def movieDownloader(request):
|
188 |
+
if request.method == 'POST':
|
189 |
+
data = json.loads(request.body)
|
190 |
+
movie = data['movie']
|
191 |
+
tmdbId = data['tmdbId']
|
192 |
+
torrentLink = data['torrentLink']
|
193 |
+
|
194 |
+
# get temp folder path
|
195 |
+
path = os
|
196 |
+
|
197 |
+
new_entry = movies(movie=movie, tmdbId=tmdbId, torrentLink=torrentLink, driveLink=driveLink)
|
198 |
+
new_entry.save()
|
199 |
+
return HttpResponse(json.dumps({'status': 'success'}), content_type='application/json')
|
200 |
|
201 |
|
202 |
def ipGetter(request):
|
|
|
205 |
if ipIn is None:
|
206 |
new_entry = ip_address(ip=ip)
|
207 |
new_entry.save()
|
|
|
208 |
return HttpResponse(json.dumps({'status': 'success'}), content_type='application/json')
|
209 |
|
210 |
|
|
|
223 |
my_map1.save('templates/godMode.html')
|
224 |
return render(request, 'godMode.html')
|
225 |
|
226 |
+
|