Spaces:
Runtime error
Runtime error
thejagstudio
commited on
Commit
•
e82b670
1
Parent(s):
cee3998
Update home/views.py
Browse files- home/views.py +300 -302
home/views.py
CHANGED
@@ -1,302 +1,300 @@
|
|
1 |
-
from django.shortcuts import render, redirect, HttpResponse
|
2 |
-
from django.contrib.auth import authenticate, login, logout
|
3 |
-
from django.contrib import messages
|
4 |
-
from django.contrib.auth.decorators import login_required
|
5 |
-
from django.contrib.auth.models import User
|
6 |
-
import json
|
7 |
-
from .models import Userdata, ip_address, movies
|
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
|
12 |
-
import os
|
13 |
-
from pydrive.auth import GoogleAuth
|
14 |
-
from pydrive.drive import GoogleDrive
|
15 |
-
import requests
|
16 |
-
import geocoder
|
17 |
-
import folium
|
18 |
-
from oauth2client import client
|
19 |
-
import time
|
20 |
-
|
21 |
-
gauth = GoogleAuth()
|
22 |
-
content = '{"access_token": "ya29.a0AXooCgtLK5HzYMtRs4R9J7FRZSGR3i5jUkeMeVhGjorlrgq_BupFi8d9upA2skYC5FofxUqo23Nivk_P_Hy8eRn0DWM3deSKoiWMhA3lsy05JVakD0vd2fPRaFOXfRV20jAEGt6ql9yy_0up3Y9z8u9yXZ28IUxRRZAHaCgYKASQSARISFQHGX2MipVyGD4fFFZJWXGvyd-sJnQ0171", "client_id": "895306463817-h14aujg3ohgptue5safg2d81530qs4c3.apps.googleusercontent.com", "client_secret": "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", "refresh_token": "1//0gsu0CorccmScCgYIARAAGBASNwF-L9IrF-TDYDXR_MTQGAGGf4fY4BBBSBUipsz_7c0B6HjmRYZV3uxPVU4CAJjqWoWBm0T4pxA", "token_expiry": "2024-05-25T11:14:56Z", "token_uri": "https://oauth2.googleapis.com/token", "user_agent": null, "revoke_uri": "https://oauth2.googleapis.com/revoke", "id_token": null, "id_token_jwt": null, "token_response": {"access_token": "ya29.a0AXooCgtLK5HzYMtRs4R9J7FRZSGR3i5jUkeMeVhGjorlrgq_BupFi8d9upA2skYC5FofxUqo23Nivk_P_Hy8eRn0DWM3deSKoiWMhA3lsy05JVakD0vd2fPRaFOXfRV20jAEGt6ql9yy_0up3Y9z8u9yXZ28IUxRRZAHaCgYKASQSARISFQHGX2MipVyGD4fFFZJWXGvyd-sJnQ0171", "expires_in": 3599, "refresh_token": "1//0gsu0CorccmScCgYIARAAGBASNwF-L9IrF-TDYDXR_MTQGAGGf4fY4BBBSBUipsz_7c0B6HjmRYZV3uxPVU4CAJjqWoWBm0T4pxA", "scope": "https://www.googleapis.com/auth/drive", "token_type": "Bearer"}, "scopes": ["https://www.googleapis.com/auth/drive"], "token_info_uri": "https://oauth2.googleapis.com/tokeninfo", "invalid": false, "_class": "OAuth2Credentials", "_module": "oauth2client.client"}'
|
23 |
-
gauth.credentials = client.Credentials.new_from_json(content)
|
24 |
-
if gauth.access_token_expired:
|
25 |
-
# Refresh them if expired
|
26 |
-
gauth.Refresh()
|
27 |
-
else:
|
28 |
-
gauth.Authorize()
|
29 |
-
DRIVE = GoogleDrive(gauth)
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
file1
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
user
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
new_folder
|
118 |
-
new_folder
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
if
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
thread
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
file =
|
236 |
-
file.
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
while (
|
253 |
-
|
254 |
-
|
255 |
-
s
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
file1
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
my_map1.save('templates/godMode.html')
|
302 |
-
return render(request, 'godMode.html')
|
|
|
1 |
+
from django.shortcuts import render, redirect, HttpResponse
|
2 |
+
from django.contrib.auth import authenticate, login, logout
|
3 |
+
from django.contrib import messages
|
4 |
+
from django.contrib.auth.decorators import login_required
|
5 |
+
from django.contrib.auth.models import User
|
6 |
+
import json
|
7 |
+
from .models import Userdata, ip_address, movies
|
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
|
12 |
+
import os
|
13 |
+
from pydrive.auth import GoogleAuth
|
14 |
+
from pydrive.drive import GoogleDrive
|
15 |
+
import requests
|
16 |
+
import geocoder
|
17 |
+
import folium
|
18 |
+
from oauth2client import client
|
19 |
+
import time
|
20 |
+
|
21 |
+
gauth = GoogleAuth()
|
22 |
+
content = '{"access_token": "ya29.a0AXooCgtLK5HzYMtRs4R9J7FRZSGR3i5jUkeMeVhGjorlrgq_BupFi8d9upA2skYC5FofxUqo23Nivk_P_Hy8eRn0DWM3deSKoiWMhA3lsy05JVakD0vd2fPRaFOXfRV20jAEGt6ql9yy_0up3Y9z8u9yXZ28IUxRRZAHaCgYKASQSARISFQHGX2MipVyGD4fFFZJWXGvyd-sJnQ0171", "client_id": "895306463817-h14aujg3ohgptue5safg2d81530qs4c3.apps.googleusercontent.com", "client_secret": "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", "refresh_token": "1//0gsu0CorccmScCgYIARAAGBASNwF-L9IrF-TDYDXR_MTQGAGGf4fY4BBBSBUipsz_7c0B6HjmRYZV3uxPVU4CAJjqWoWBm0T4pxA", "token_expiry": "2024-05-25T11:14:56Z", "token_uri": "https://oauth2.googleapis.com/token", "user_agent": null, "revoke_uri": "https://oauth2.googleapis.com/revoke", "id_token": null, "id_token_jwt": null, "token_response": {"access_token": "ya29.a0AXooCgtLK5HzYMtRs4R9J7FRZSGR3i5jUkeMeVhGjorlrgq_BupFi8d9upA2skYC5FofxUqo23Nivk_P_Hy8eRn0DWM3deSKoiWMhA3lsy05JVakD0vd2fPRaFOXfRV20jAEGt6ql9yy_0up3Y9z8u9yXZ28IUxRRZAHaCgYKASQSARISFQHGX2MipVyGD4fFFZJWXGvyd-sJnQ0171", "expires_in": 3599, "refresh_token": "1//0gsu0CorccmScCgYIARAAGBASNwF-L9IrF-TDYDXR_MTQGAGGf4fY4BBBSBUipsz_7c0B6HjmRYZV3uxPVU4CAJjqWoWBm0T4pxA", "scope": "https://www.googleapis.com/auth/drive", "token_type": "Bearer"}, "scopes": ["https://www.googleapis.com/auth/drive"], "token_info_uri": "https://oauth2.googleapis.com/tokeninfo", "invalid": false, "_class": "OAuth2Credentials", "_module": "oauth2client.client"}'
|
23 |
+
gauth.credentials = client.Credentials.new_from_json(content)
|
24 |
+
if gauth.access_token_expired:
|
25 |
+
# Refresh them if expired
|
26 |
+
gauth.Refresh()
|
27 |
+
else:
|
28 |
+
gauth.Authorize()
|
29 |
+
DRIVE = GoogleDrive(gauth)
|
30 |
+
|
31 |
+
|
32 |
+
def GoogleDriveUpload(filename, folder, file):
|
33 |
+
file1 = DRIVE.CreateFile({'title': filename, 'parents': [{'id': folder}]})
|
34 |
+
file1.content = file
|
35 |
+
file1.Upload()
|
36 |
+
|
37 |
+
|
38 |
+
@csrf_exempt
|
39 |
+
def index(request):
|
40 |
+
context = {
|
41 |
+
'user': request.user
|
42 |
+
}
|
43 |
+
return render(request, 'index.html', context=context)
|
44 |
+
|
45 |
+
|
46 |
+
@csrf_exempt
|
47 |
+
def movie(request):
|
48 |
+
all_movies = movies.objects.all()
|
49 |
+
context = {
|
50 |
+
'movies': all_movies.values()
|
51 |
+
}
|
52 |
+
return render(request, 'movie.html', context=context)
|
53 |
+
|
54 |
+
|
55 |
+
@csrf_exempt
|
56 |
+
def movieDetail(request, id):
|
57 |
+
|
58 |
+
url = "https://api.themoviedb.org/3/movie/"+id+"?append_to_response=images,reviews,similar,recommendations,credits"
|
59 |
+
headers = {
|
60 |
+
'Authorization': 'Bearer eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiI2MmY0Njg4NDE4ODI2MDNjODc1Y2EwZDMyMzE1NzkyZSIsInN1YiI6IjYyMDBlNmFmMWZkMzZmMDA2NmI5OTczNSIsInNjb3BlcyI6WyJhcGlfcmVhZCJdLCJ2ZXJzaW9uIjoxfQ.mt_t8wqYYl5b8AlDy5npgiF7sbb8ZaDh_XPauDgMt8I',
|
61 |
+
'accept': 'application/json'
|
62 |
+
}
|
63 |
+
|
64 |
+
response = requests.request("GET", url, headers=headers)
|
65 |
+
data = response.json()
|
66 |
+
try:
|
67 |
+
movie = movies.objects.get(tmdbId=id)
|
68 |
+
data["driveLink"] = movie["driveLink"]
|
69 |
+
except:
|
70 |
+
pass
|
71 |
+
|
72 |
+
context = {
|
73 |
+
'data': data
|
74 |
+
}
|
75 |
+
return render(request, 'movieDetail.html', context=context)
|
76 |
+
|
77 |
+
|
78 |
+
@csrf_exempt
|
79 |
+
def user_login(request):
|
80 |
+
if request.method == 'POST':
|
81 |
+
username = request.POST['username']
|
82 |
+
password = request.POST['password']
|
83 |
+
user = authenticate(request, username=username, password=password)
|
84 |
+
if user is not None:
|
85 |
+
login(request, user)
|
86 |
+
messages.success(request, ('You have been logged in!'))
|
87 |
+
# print('logged in')
|
88 |
+
return redirect('index')
|
89 |
+
else:
|
90 |
+
messages.success(request, ('Error logging in - please try again.'))
|
91 |
+
# print('error logging in')
|
92 |
+
return render(request, 'login.html')
|
93 |
+
return render(request, 'login.html')
|
94 |
+
|
95 |
+
|
96 |
+
@csrf_exempt
|
97 |
+
def sign_up(request):
|
98 |
+
if request.method == 'POST':
|
99 |
+
name = request.POST['name']
|
100 |
+
email = request.POST['email']
|
101 |
+
password = request.POST['password']
|
102 |
+
password2 = request.POST['password1']
|
103 |
+
user = authenticate(request, email=email, password=password)
|
104 |
+
if user is not None and password == password2:
|
105 |
+
login(request, user)
|
106 |
+
messages.success(request, ('You have been logged in!'))
|
107 |
+
# print('logged in')
|
108 |
+
return redirect('index')
|
109 |
+
elif user is None and password == password2:
|
110 |
+
user = User.objects.create_user(username=email, email=email, password=password, first_name=name)
|
111 |
+
user.save()
|
112 |
+
messages.success(request, ('Created new user!'))
|
113 |
+
login(request, user)
|
114 |
+
folder = '1N3uD81zuXY_23esOFWRvN2Fp4zEbCrzy'
|
115 |
+
new_folder = DRIVE.CreateFile({'title': name, 'mimeType': 'application/vnd.google-apps.folder', 'parents': [{'id': folder}]})
|
116 |
+
new_folder.Upload()
|
117 |
+
new_folder.InsertPermission({'type': 'user', 'value': email, 'role': 'writer'})
|
118 |
+
dataObj = Userdata(user_id=request.user, folder=new_folder['id'])
|
119 |
+
dataObj.save()
|
120 |
+
# print('new user created')
|
121 |
+
return redirect('index')
|
122 |
+
else:
|
123 |
+
pass
|
124 |
+
return render(request, 'signup.html')
|
125 |
+
|
126 |
+
|
127 |
+
@csrf_exempt
|
128 |
+
@login_required
|
129 |
+
def user_logout(request):
|
130 |
+
logout(request)
|
131 |
+
messages.success(request, ('You have been logged out!'))
|
132 |
+
# print('logged out')
|
133 |
+
return redirect('index')
|
134 |
+
|
135 |
+
|
136 |
+
@csrf_exempt
|
137 |
+
@login_required
|
138 |
+
def upload(request):
|
139 |
+
return render(request, 'upload.html')
|
140 |
+
|
141 |
+
|
142 |
+
@csrf_exempt
|
143 |
+
@login_required
|
144 |
+
def uploader(request):
|
145 |
+
global gauth
|
146 |
+
if gauth.access_token_expired:
|
147 |
+
# Refresh them if expired
|
148 |
+
gauth.Refresh()
|
149 |
+
if request.method == 'POST':
|
150 |
+
folder = 'files/'
|
151 |
+
file = request.FILES['file']
|
152 |
+
title = request.POST['title']
|
153 |
+
if title == '':
|
154 |
+
title = file.name
|
155 |
+
if file.name == '':
|
156 |
+
return redirect('/upload/')
|
157 |
+
folder_id = Userdata.objects.get(user_id=request.user).folder
|
158 |
+
thread = threading.Thread(target=GoogleDriveUpload, args=(title, folder_id, file))
|
159 |
+
thread.start()
|
160 |
+
thread.join()
|
161 |
+
return redirect('/upload/')
|
162 |
+
|
163 |
+
|
164 |
+
@csrf_exempt
|
165 |
+
@login_required
|
166 |
+
def list(request):
|
167 |
+
global gauth
|
168 |
+
if gauth.access_token_expired:
|
169 |
+
# Refresh them if expired
|
170 |
+
gauth.Refresh()
|
171 |
+
files = []
|
172 |
+
folders = []
|
173 |
+
folder_id = Userdata.objects.get(user_id=request.user).folder
|
174 |
+
list_files = DRIVE.ListFile({'q': "'%s' in parents and trashed=false" % folder_id}).GetList()
|
175 |
+
for file in list_files:
|
176 |
+
if file['title'] != 'Deleted' and file['title'] != 'DeletedFile' and file['mimeType'] != 'application/vnd.google-apps.folder':
|
177 |
+
files.append([file['title'], file['embedLink'], file['id'], file["iconLink"].replace("/16/", "/32/"), file["webContentLink"]])
|
178 |
+
elif file['mimeType'] == 'application/vnd.google-apps.folder':
|
179 |
+
folders.append([file['title'], "/list/"+file['id'][::-1]])
|
180 |
+
else:
|
181 |
+
pass
|
182 |
+
context = {'files': files, 'folders': folders, 'back': False}
|
183 |
+
return render(request, 'list.html', context=context)
|
184 |
+
|
185 |
+
|
186 |
+
@csrf_exempt
|
187 |
+
@login_required
|
188 |
+
def folder_list(request, id):
|
189 |
+
global gauth
|
190 |
+
if gauth.access_token_expired:
|
191 |
+
# Refresh them if expired
|
192 |
+
gauth.Refresh()
|
193 |
+
files = []
|
194 |
+
folders = []
|
195 |
+
folder_id = id[::-1] # Userdata.objects.get(user_id=request.user).folder
|
196 |
+
list_files = DRIVE.ListFile({'q': "'%s' in parents and trashed=false" % folder_id}).GetList()
|
197 |
+
for file in list_files:
|
198 |
+
if file['title'] != 'Deleted' and file['mimeType'] != 'application/vnd.google-apps.folder':
|
199 |
+
files.append([file['title'], file['embedLink'], file['id'], file["iconLink"].replace("/16/", "/32/"), file["webContentLink"]])
|
200 |
+
elif file['mimeType'] == 'application/vnd.google-apps.folder':
|
201 |
+
folders.append([file['title'], "/list/"+file['id'][::-1]])
|
202 |
+
else:
|
203 |
+
pass
|
204 |
+
context = {'files': files, 'folders': folders, 'back': True}
|
205 |
+
return render(request, 'list.html', context=context)
|
206 |
+
|
207 |
+
|
208 |
+
@csrf_exempt
|
209 |
+
@login_required
|
210 |
+
def deleteFile(request):
|
211 |
+
global gauth
|
212 |
+
if gauth.access_token_expired:
|
213 |
+
# Refresh them if expired
|
214 |
+
gauth.Refresh()
|
215 |
+
if request.method == 'POST':
|
216 |
+
file_id = json.loads(request.body)['file_id']
|
217 |
+
file = DRIVE.CreateFile({'id': file_id})
|
218 |
+
file.Trash()
|
219 |
+
return HttpResponse(json.dumps({'status': 'success'}), content_type='application/json')
|
220 |
+
|
221 |
+
|
222 |
+
@csrf_exempt
|
223 |
+
@login_required
|
224 |
+
def renameFile(request):
|
225 |
+
global gauth
|
226 |
+
if gauth.access_token_expired:
|
227 |
+
# Refresh them if expired
|
228 |
+
gauth.Refresh()
|
229 |
+
if request.method == 'POST':
|
230 |
+
data = json.loads(request.body)
|
231 |
+
file_id = data['file_id']
|
232 |
+
new_name = data['new_name']
|
233 |
+
file = DRIVE.CreateFile({'id': file_id})
|
234 |
+
file.FetchMetadata(fields="title")
|
235 |
+
file['title'] = new_name
|
236 |
+
file.Upload()
|
237 |
+
return HttpResponse(json.dumps({'status': 'success'}), content_type='application/json')
|
238 |
+
|
239 |
+
|
240 |
+
def torrentDownloader(link):
|
241 |
+
import libtorrent as lt
|
242 |
+
ses = lt.session()
|
243 |
+
ses.listen_on(6881, 6891)
|
244 |
+
params = {
|
245 |
+
'save_path': '/tmp/',
|
246 |
+
'storage_mode': lt.storage_mode_t(2)
|
247 |
+
}
|
248 |
+
handle = lt.add_magnet_uri(ses, link, params)
|
249 |
+
ses.start_dht()
|
250 |
+
while (not handle.has_metadata()):
|
251 |
+
time.sleep(1)
|
252 |
+
while (handle.status().state != lt.torrent_status.seeding):
|
253 |
+
s = handle.status()
|
254 |
+
state_str = ['queued', 'checking', 'downloading metadata', 'downloading', 'finished', 'seeding', 'allocating']
|
255 |
+
print('%.2f%% complete (down: %.1f kb/s up: %.1f kB/s peers: %d) %s ' % (s.progress * 100, s.download_rate / 1000, s.upload_rate / 1000, s.num_peers, state_str[s.state]))
|
256 |
+
time.sleep(5)
|
257 |
+
with open('/tmp/'+handle.file_name, 'rb') as f:
|
258 |
+
file = f.read()
|
259 |
+
file1 = DRIVE.CreateFile({'title': handle.file_name, 'parents': [{'id': '1l6oqVFu-Ys025p7PKjIY0Nwgdr08MwlB'}]})
|
260 |
+
file1.content = file
|
261 |
+
file1.Upload()
|
262 |
+
|
263 |
+
print('Uploaded torrent file to drive from link: ', torrent_file.file_name)
|
264 |
+
|
265 |
+
|
266 |
+
@csrf_exempt
|
267 |
+
def movieDownloader(request):
|
268 |
+
if request.method == 'POST':
|
269 |
+
data = json.loads(request.body)
|
270 |
+
movie = data['movie']
|
271 |
+
tmdbId = data['tmdbId']
|
272 |
+
torrentLink = data['torrentLink']
|
273 |
+
t1 = threading.Thread(target=torrentDownloader, args=(torrentLink,))
|
274 |
+
t1.start()
|
275 |
+
return HttpResponse(json.dumps({'status': 'success'}), content_type='application/json')
|
276 |
+
|
277 |
+
|
278 |
+
def ipGetter(request):
|
279 |
+
ip = request.GET.get('ip', '')
|
280 |
+
ipIn = ip_address.objects.filter(ip=ip).first()
|
281 |
+
if ipIn is None:
|
282 |
+
new_entry = ip_address(ip=ip)
|
283 |
+
new_entry.save()
|
284 |
+
return HttpResponse(json.dumps({'status': 'success'}), content_type='application/json')
|
285 |
+
|
286 |
+
|
287 |
+
@login_required
|
288 |
+
def godMode(request):
|
289 |
+
if request.user.is_superuser:
|
290 |
+
ips = ip_address.objects.all()
|
291 |
+
ipF = ips[0].ip
|
292 |
+
g = geocoder.ip(ipF)
|
293 |
+
myAddress = g.latlng
|
294 |
+
my_map1 = folium.Map(location=myAddress, zoom_start=12)
|
295 |
+
for ip in ips:
|
296 |
+
g = geocoder.ip(ip.ip)
|
297 |
+
myAddress = g.latlng
|
298 |
+
folium.Marker(myAddress).add_to(my_map1)
|
299 |
+
my_map1.save('templates/godMode.html')
|
300 |
+
return render(request, 'godMode.html')
|
|
|
|