-
Notifications
You must be signed in to change notification settings - Fork 2
/
Anime.py
110 lines (90 loc) · 3.48 KB
/
Anime.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
from xdm.plugins import *
from xdm.tasks import updateElement
from json import loads
import os
location = os.path.abspath(os.path.dirname(__file__))
class Episode(object):
number = 0
title = ''
special = False
overview = ''
screencap_image = ''
_orderBy = 'number'
_orderReverse = True
def getSearchTerms(self):
return ['%s %02d' % (self.parent.title, self.number)]
""" The user should be able to choose which anime-synonym to search for
return ['%s %02d' % (s, self.number) for s in loads(self.parent.synonyms)]
"""
def getTemplate(self):
fp = os.path.join(location, "episode.ji2")
with open (fp, "r") as template:
return template.read()
def getName(self):
return "%s e%02d %s" % (self.parent.getName(), self.number, self.title)
def getReleaseDate(self):
return self.airdate
def getIdentifier(self, tag=None):
return self.number
class Show(object):
title = ''
description = ''
poster_image = 1
fanart_image = 2
runtime = ''
classification = ''
id = ''
synonyms = ''
_orderBy = 'title'
def getName(self):
return self.title
def getIdentifier(self, tag=None):
return self.getField('id', tag)
def getTemplate(self):
fp = os.path.join(location, "show.ji2")
with open (fp, "r") as template:
return template.read()
def getSearchTemplate(self):
fp = os.path.join(location, "show_search.ji2")
with open (fp, "r") as template:
return template.read()
class Anime(MediaTypeManager):
version = "0.4"
single = True
_config = {'enabled': True,
'page_size': 15}
config_meta = {'plugin_desc': 'Anime support'}
order = (Show, Episode)
download = Episode
identifier = 'de.uranime.anime'
addConfig = {}
addConfig[Downloader] = [{'type':'category', 'default': None, 'prefix': 'Category for', 'sufix': 'Anime'}]
addConfig[Indexer] = [{'type':'category', 'default': None, 'prefix': 'Category for', 'sufix': 'Anime'}]
addConfig[PostProcessor] = [{'type':'path', 'default': None, 'prefix': 'Final path for', 'sufix': 'Anime'}]
def makeReal(self, show, status):
show.parent = self.root
log("{}{}{}".format(show, status, common.getStatusByID(self.c.default_new_status_select)))
show.status = common.getStatusByID(self.c.default_new_status_select)
show.save()
common.Q.put(('image.download', {'id': show.id}))
for episode in list(show.children):
episode.save()
common.Q.put(('image.download', {'id': episode.id}))
updateElement(show)
return True
def headInject(self):
return """
<link rel="stylesheet" href="%(myUrl)s/style.css">
<script>var uranime_page_size = %(page_size)s;</script>
<script src="%(myUrl)s/jquery.dataTables.min.js"></script>
<script src="%(myUrl)s/script.js"></script>
""" % {'myUrl': self.myUrl(),
'page_size': self.c.page_size}
def _episode_count(self, anime, statuses=False):
if statuses:
return Element.select().where(Element.type == 'Episode',
Element.parent == anime,
Element.status << statuses).count()
else:
return Element.select().where(Element.type == 'Episode',
Element.parent == anime).count()