-
Notifications
You must be signed in to change notification settings - Fork 0
/
addon.py
88 lines (64 loc) · 2.37 KB
/
addon.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
import sys
import xbmc
import xbmcgui
import xbmcplugin
import xbmcaddon
import requests
import json
import re
import urllib
from lxml import html
from urlparse import parse_qsl
from datetime import datetime, timedelta
from libs import phpscraper
# https://forum.kodi.tv/showthread.php?tid=324570
addon = xbmcaddon.Addon()
_pid = sys.argv[0]
_handle = int(sys.argv[1])
def list_categories():
xbmcplugin.setPluginCategory(_handle, 'ACE')
xbmcplugin.setContent(_handle, 'videos')
listitem = xbmcgui.ListItem(label=' Refresh List')
listitem.setInfo('video', {'title': ' Refresh List', 'mediatype': 'video'})
xbmcplugin.addDirectoryItem(handle=_handle, url=_pid, listitem=listitem, isFolder=True)
listitem = xbmcgui.ListItem(label="PHP Scrapers")
listitem.setInfo('video', {'title': "PHP Scrapers", 'mediatype': 'video'})
data = {
"provider": 'phpscraper',
"action": "list",
"title": "PHP Scrapers",
"link": ""
}
xbmcplugin.addDirectoryItem(handle=_handle, url='{0}?data={1}'.format(_pid, urllib.quote(json.dumps(data))), listitem=listitem, isFolder=True)
for tmp in addon.getSetting('acestreamsearch_terms').split(","):
listitem = xbmcgui.ListItem(label='ASS {}'.format(tmp))
listitem.setInfo('video', {'title': 'ASS {}'.format(tmp), 'mediatype': 'video'})
data = {
"provider": 'phpscraper',
"action": "acestreamsearch-search-0",
"title": 'ASS {}'.format(tmp),
"link": tmp
}
xbmcplugin.addDirectoryItem(handle=_handle, url='{0}?data={1}'.format(_pid, urllib.quote(json.dumps(data))), listitem=listitem, isFolder=True)
xbmcplugin.endOfDirectory(_handle)
def play_video(path):
xbmcplugin.setResolvedUrl(_handle, True, listitem=xbmcgui.ListItem(path=path))
xbmc.log(" ".join(sys.argv), xbmc.LOGNOTICE)
def router(paramstring):
try:
params = json.loads(urllib.unquote(paramstring[5:]))
except Exception as e:
xbmc.log("type error: " + str(e), xbmc.LOGERROR)
params = False
if params:
if params['action'] == 'play':
play_video(params['video'])
elif params['provider'] == 'phpscraper':
try:
phpscraper.build_list(_pid, _handle, addon, params['action'], params['title'], params['link'])
except Exception as e:
xbmc.log("type error: " + str(e), xbmc.LOGERROR)
else:
list_categories()
if __name__ == '__main__':
router(sys.argv[2][1:])