Spaces:
Runtime error
Runtime error
Update home/views.py
Browse files- home/views.py +0 -24
home/views.py
CHANGED
|
@@ -16,8 +16,6 @@ import requests
|
|
| 16 |
import geocoder
|
| 17 |
import folium
|
| 18 |
from oauth2client import client
|
| 19 |
-
import libtorrent as lt
|
| 20 |
-
|
| 21 |
gauth = GoogleAuth()
|
| 22 |
content = os.environ.get('token')
|
| 23 |
gauth.credentials = client.Credentials.new_from_json(content)
|
|
@@ -31,28 +29,6 @@ DRIVE = GoogleDrive(gauth)
|
|
| 31 |
|
| 32 |
def torrentDownloader(link):
|
| 33 |
print(link)
|
| 34 |
-
ses = lt.session()
|
| 35 |
-
ses.listen_on(6881, 6891)
|
| 36 |
-
params = {
|
| 37 |
-
'save_path': '/tmp/',
|
| 38 |
-
'storage_mode': lt.storage_mode_t(2)
|
| 39 |
-
}
|
| 40 |
-
handle = lt.add_magnet_uri(ses, link, params)
|
| 41 |
-
ses.start_dht()
|
| 42 |
-
while (not handle.has_metadata()):
|
| 43 |
-
time.sleep(1)
|
| 44 |
-
while (handle.status().state != lt.torrent_status.seeding):
|
| 45 |
-
s = handle.status()
|
| 46 |
-
state_str = ['queued', 'checking', 'downloading metadata', 'downloading', 'finished', 'seeding', 'allocating']
|
| 47 |
-
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]))
|
| 48 |
-
time.sleep(5)
|
| 49 |
-
with open('/tmp/'+handle.file_name, 'rb') as f:
|
| 50 |
-
file = f.read()
|
| 51 |
-
file1 = DRIVE.CreateFile({'title': handle.file_name, 'parents': [{'id': '1l6oqVFu-Ys025p7PKjIY0Nwgdr08MwlB'}]})
|
| 52 |
-
file1.content = file
|
| 53 |
-
file1.Upload()
|
| 54 |
-
|
| 55 |
-
print('Uploaded torrent file to drive from link: ', torrent_file.file_name)
|
| 56 |
|
| 57 |
|
| 58 |
@csrf_exempt
|
|
|
|
| 16 |
import geocoder
|
| 17 |
import folium
|
| 18 |
from oauth2client import client
|
|
|
|
|
|
|
| 19 |
gauth = GoogleAuth()
|
| 20 |
content = os.environ.get('token')
|
| 21 |
gauth.credentials = client.Credentials.new_from_json(content)
|
|
|
|
| 29 |
|
| 30 |
def torrentDownloader(link):
|
| 31 |
print(link)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
|
| 34 |
@csrf_exempt
|