-
Notifications
You must be signed in to change notification settings - Fork 0
/
addon.py
142 lines (124 loc) · 6.12 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
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# -*- coding: utf-8 -*-
# Copyright (C) 2024 gbchr
from resources.lib import providers, routing, utils, windows
FIRST_PAGE = 1
plugin = routing.Plugin()
@plugin.route('/')
def index():
# search
utils.createFolder(input_query, utils.localStr(32000), [], image=utils.search_img, thumb=utils.search_img)
# comics
utils.createFolder(index, utils.localStr(32008), [], image=utils.comics_img, thumb=utils.comics_img) # separator
utils.createFolder(popular, utils.localStr(32001), ['hq', FIRST_PAGE], image=utils.popular_img, thumb=utils.popular_img)
utils.createFolder(recommended_comics, utils.localStr(32003), [], image=utils.recommended_img, thumb=utils.recommended_img)
utils.createFolder(specific_keyword, utils.localStr(32004), ['hq','marvel',FIRST_PAGE], image=utils.marvel_img, thumb=utils.marvel_img)
utils.createFolder(specific_keyword, utils.localStr(32005), ['hq','dc',FIRST_PAGE], image=utils.dc_img, thumb=utils.dc_img)
utils.createFolder(specific_keyword, utils.localStr(32010), ['hq','darkhorse',FIRST_PAGE], image=utils.darkhorse_img, thumb=utils.darkhorse_img)
utils.createFolder(list_letters, utils.localStr(32043), [], image=utils.letter_img, thumb=utils.letter_img)
# mangas
utils.createFolder(index, utils.localStr(32009), [], image=utils.mangas_img, thumb=utils.mangas_img) # separator
utils.createFolder(popular, utils.localStr(32002), ['manga', FIRST_PAGE], image=utils.popular_img, thumb=utils.popular_img)
utils.createFolder(recommended_mangas, utils.localStr(32003), [], image=utils.recommended_img, thumb=utils.recommended_img)
utils.endDirectory()
@plugin.route('/list_letters')
def list_letters():
for i in utils.localStr(32042).split('|'):
utils.createFolder(specific_keyword, i, ['hq', 'by_letter', FIRST_PAGE, i])
utils.endDirectory()
@plugin.route('/recommended_comics')
def recommended_comics():
for i in sorted(utils.localStr(32011).split('|')):
utils.createFolder(search, i, [i, FIRST_PAGE])
utils.endDirectory()
@plugin.route('/recommended_mangas')
def recommended_mangas():
for i in sorted(utils.localStr(32012).split('|')):
utils.createFolder(search, i, [i, FIRST_PAGE])
utils.endDirectory()
@plugin.route('/input_query')
def input_query():
text = utils.keyboard(utils.read_query(), utils.localStr(32000))
if text != None:
utils.save_query(text)
search(text, FIRST_PAGE)
else: index()
@plugin.route('/search/<query>/<page>')
def search(query, page):
results = providers.search(query, page)
for result in results:
utils.createFolder(list_chapters,
result['title'],
[result['provider'], result['link'], FIRST_PAGE],
image = result['image'],
plot = result['plot'])
if int(page) > 1 and utils.get_setting('previous_page_item', bool):
utils.createFolder(search, utils.localStr(32007), [query, int(page) - 1], utils.previous_page_img, "", utils.previous_page_img)
if len(results) > 0:
utils.createFolder(search, utils.localStr(32006), [query, int(page) + 1], utils.next_page_img, "", utils.next_page_img)
utils.endDirectory(cache=True)
@plugin.route('/popular/<type>/<page>')
def popular(type, page):
results = providers.popular(type, page)
for result in results:
utils.createFolder(list_chapters,
result['title'],
[result['provider'], result['link'], FIRST_PAGE],
image = result['image'],
plot = result['plot'])
if int(page) > 1 and utils.get_setting('previous_page_item', bool):
utils.createFolder(popular, utils.localStr(32007), [type, int(page) - 1], utils.previous_page_img, "", utils.previous_page_img)
if len(results) > 0:
utils.createFolder(popular, utils.localStr(32006), [type, int(page) + 1], utils.next_page_img, "", utils.next_page_img)
utils.endDirectory(cache=True)
@plugin.route('/specific_keyword/<type>/<keyword>/<page>/<query>')
@plugin.route('/specific_keyword/<type>/<keyword>/<page>')
def specific_keyword(type, keyword, page, query = ''):
results = providers.by_keyword(type, keyword, page, query)
for result in results:
utils.createFolder(list_chapters,
result['title'],
[result['provider'], result['link'], FIRST_PAGE],
image = result['image'],
plot = result['plot'])
if int(page) > 1 and utils.get_setting('previous_page_item', bool):
utils.createFolder(specific_keyword, utils.localStr(32007), [type, keyword, int(page) - 1], utils.previous_page_img, "", utils.previous_page_img)
if len(results) > 0:
utils.createFolder(specific_keyword, utils.localStr(32006), [type, keyword, int(page) + 1], utils.next_page_img, "", utils.next_page_img)
utils.endDirectory(cache=True)
@plugin.route('/chapters/<provider_name>/<url>/<page>')
def list_chapters(provider_name, url, page):
results = providers.do_list_chapters(provider_name, url, page)
for r in results:
utils.createFolder(list_pages,
r['title'],
[r['provider'], r['link'], utils.base64_encode(r['title'])],
plot = r['plot'],
image = r['image'],
thumb = r['image'])
if int(page) > 1 and utils.get_setting('previous_page_item', bool):
utils.createFolder(list_chapters, utils.localStr(32007), [provider_name, url, int(page) - 1], utils.previous_page_img, "", utils.previous_page_img)
pagination = providers.has_pagination(providers.provider_by_name(provider_name)['chapters']['request'])
if len(results) > 0 and pagination:
utils.createFolder(list_chapters, utils.localStr(32006), [provider_name, url, int(page) + 1], utils.next_page_img, "", utils.next_page_img)
utils.endDirectory(cache=True)
@plugin.route('/pages/<provider_name>/<url>/<chapter_title>')
@plugin.route('/pages/<provider_name>/<url>')
def list_pages(provider_name, url, chapter_title = ''):
use_custom_gui = utils.get_setting('custom_gui', bool)
results = providers.do_list_pages(provider_name, url)
if not use_custom_gui:
for r in results:
link = utils.base64_decode_url(r['link'])
utils.createItem(link, r['title'], link)
utils.endDirectory()
else:
window = windows.PagesWindow(title = utils.base64_decode(chapter_title),
pages = results,
headers = providers.get_headers(provider_name, 'pages') )
window.doModal()
del window
if __name__ == '__main__':
utils.plugin = plugin
utils.set_content('images')
utils.log('init')
plugin.run()