-
Notifications
You must be signed in to change notification settings - Fork 0
/
tribler.py
125 lines (93 loc) · 3.28 KB
/
tribler.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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
114
115
116
117
118
119
120
121
122
123
124
125
import os
import sys
import time
import urlparse
import xbmcaddon
from requests.exceptions import ConnectionError
from os.path import join, abspath, dirname
from resources.lib.module.setting import Setting
args = dict(urlparse.parse_qsl(sys.argv[2].replace('?','')))
action = args.get('action')
channel_id = args.get('channel-id')
info_hash = args.get('info-hash')
name = args.get('name')
keyword = args.get('keyword')
API_PORT = 8085
setting = None
# import xbmc
# xbmc.log('python %s $' % join(xbmcaddon.Addon().getAddonInfo('path'), 'service.py'))
path = xbmcaddon.Addon().getAddonInfo('path')
while not setting:
try:
setting = Setting(API_PORT)
except:
os.system('python %s/service.py $' % path)
# time.sleep(3)
if action == None:
from resources.lib.menu import navigator
navigator.Navigator().root()
elif action == 'recommanded':
from resources.lib.menu import navigator
navigator.Navigator().recommanded()
elif action == 'discovered':
from resources.lib.menu import channel
channel.Channel().discovered()
elif action == 'my-channel':
from resources.lib.menu import navigator
navigator.Navigator().my_channel()
elif action == 'subscriptions':
from resources.lib.menu import channel
channel.Channel().subscriptions()
elif action == 'downloads':
from resources.lib.menu import navigator
navigator.Navigator().downloads()
elif action == 'downloads-all':
from resources.lib.menu import download
download.Download().downloads_all()
elif action == 'downloads-downloading':
from resources.lib.menu import download
download.Download().downloads_downloading()
elif action == 'downloads-completed':
from resources.lib.menu import download
download.Download().downloads_completed()
elif action == 'downloads-active':
from resources.lib.menu import download
download.Download().downloads_active()
elif action == 'downloads-inactive':
from resources.lib.menu import download
download.Download().downloads_inactive()
elif action == 'search':
from resources.lib.menu import navigator
navigator.Navigator().search(API_PORT)
elif action == 'settings':
setting.open_settings()
elif action == 'recommanded-torrents':
from resources.lib.menu import torrent
torrent.Torrent().recommanded_torrents()
elif action == 'recommanded-channels':
from resources.lib.menu import channel
channel.Channel().recommanded_channels()
elif action == 'search-all':
from resources.lib.menu import search
search.Search(API_PORT, keyword).all_results()
elif action == 'search-channels':
from resources.lib.menu import search
search.Search(API_PORT, keyword).channel_results()
elif action == 'search-torrents':
from resources.lib.menu import search
search.Search(API_PORT, keyword).torrent_results()
elif action == 'open-channel':
from resources.lib.menu import torrent
torrent.Torrent().open_channel(channel_id, name)
elif action == 'subscribe':
from resources.lib.menu import channel
channel.Channel().subscribe(channel_id, name)
elif action == 'torrent-action':
from resources.lib.menu import torrent
torrent.Torrent().torrent_action(info_hash, name)
elif action == 'download-action':
from resources.lib.menu import download
download.Download().download_action(info_hash, name)
elif action == 'start-download':
from resources.lib.menu import download
download.Download().start_download(info_hash, name)