trackma 0.6.2__py3.4.egg → 0.7__py3.4.egg
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- EGG-INFO/PKG-INFO +1 -1
- EGG-INFO/SOURCES.txt +9 -6
- trackma/__pycache__/__init__.cpython-34.pyc +0 -0
- trackma/__pycache__/accounts.cpython-34.pyc +0 -0
- trackma/__pycache__/data.cpython-34.pyc +0 -0
- trackma/__pycache__/engine.cpython-34.pyc +0 -0
- trackma/__pycache__/messenger.cpython-34.pyc +0 -0
- trackma/__pycache__/utils.cpython-34.pyc +0 -0
- trackma/data/kitsu.png +0 -0
- trackma/data.py +26 -16
- trackma/engine.py +60 -16
- trackma/extras/AnimeInfoExtractor.py +1 -1
- trackma/extras/__pycache__/AnimeInfoExtractor.cpython-34.pyc +0 -0
- trackma/extras/__pycache__/__init__.cpython-34.pyc +0 -0
- trackma/lib/__pycache__/__init__.cpython-34.pyc +0 -0
- trackma/lib/__pycache__/lib.cpython-34.pyc +0 -0
- trackma/lib/__pycache__/libanilist.cpython-34.pyc +0 -0
- trackma/lib/__pycache__/libkitsu.cpython-34.pyc +0 -0
- trackma/lib/__pycache__/libmal.cpython-34.pyc +0 -0
- trackma/lib/__pycache__/libshikimori.cpython-34.pyc +0 -0
- trackma/lib/__pycache__/libvndb.cpython-34.pyc +0 -0
- trackma/lib/libanilist.py +3 -3
- trackma/lib/libkitsu.py +478 -0
- trackma/lib/libmal.py +6 -6
- trackma/lib/libshikimori.py +3 -3
- trackma/lib/libvndb.py +12 -9
- trackma/messenger.py +1 -1
- trackma/tracker/__init__.py +0 -0
- trackma/tracker/__pycache__/__init__.cpython-34.pyc +0 -0
- trackma/tracker/__pycache__/inotify.cpython-34.pyc +0 -0
- trackma/tracker/__pycache__/plex.cpython-34.pyc +0 -0
- trackma/tracker/__pycache__/polling.cpython-34.pyc +0 -0
- trackma/tracker/__pycache__/pyinotify.cpython-34.pyc +0 -0
- trackma/tracker/__pycache__/tracker.cpython-34.pyc +0 -0
- trackma/tracker/__pycache__/win32.cpython-34.pyc +0 -0
- trackma/tracker/inotify.py +123 -0
- trackma/tracker/plex.py +99 -0
- trackma/tracker/polling.py +55 -0
- trackma/tracker/pyinotify.py +143 -0
- trackma/tracker/tracker.py +213 -0
- trackma/tracker/win32.py +74 -0
- trackma/ui/__pycache__/__init__.cpython-34.pyc +0 -0
- trackma/ui/__pycache__/cli.cpython-34.pyc +0 -0
- trackma/ui/__pycache__/curses.cpython-34.pyc +0 -0
- trackma/ui/__pycache__/gtkui.cpython-34.pyc +0 -0
- trackma/ui/__pycache__/qt4ui.cpython-34.pyc +0 -0
- trackma/ui/__pycache__/qtui.cpython-34.pyc +0 -0
- trackma/ui/cli.py +109 -12
- trackma/ui/curses.py +87 -29
- trackma/ui/gtkui.py +81 -45
- trackma/ui/qtui.py +95 -34
- trackma/utils.py +15 -9
- trackma/__pycache__/tracker.cpython-34.pyc +0 -0
- trackma/data/hb.jpg +0 -0
- trackma/data/melative.jpg +0 -0
- trackma/extras/__pycache__/plex.cpython-34.pyc +0 -0
- trackma/extras/plex.py +0 -101
- trackma/lib/__pycache__/libhb.cpython-34.pyc +0 -0
- trackma/lib/__pycache__/libmelative.cpython-34.pyc +0 -0
- trackma/lib/libhb.py +0 -239
- trackma/lib/libmelative.py +0 -204
- trackma/tracker.py +0 -430
trackma/lib/libhb.py
DELETED
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
# This file is part of Trackma.
|
|
3
|
-
#
|
|
4
|
-
# This program is free software: you can redistribute it and/or modify
|
|
5
|
-
# it under the terms of the GNU General Public License as published by
|
|
6
|
-
# the Free Software Foundation, either version 3 of the License, or
|
|
7
|
-
# (at your option) any later version.
|
|
8
|
-
#
|
|
9
|
-
# This program is distributed in the hope that it will be useful,
|
|
10
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
-
# GNU General Public License for more details.
|
|
13
|
-
#
|
|
14
|
-
# You should have received a copy of the GNU General Public License
|
|
15
|
-
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
-
#
|
|
17
|
-
|
|
18
|
-
import datetime
|
|
19
|
-
import urllib.parse
|
|
20
|
-
import urllib.request
|
|
21
|
-
import json
|
|
22
|
-
|
|
23
|
-
from trackma.lib.lib import lib
|
|
24
|
-
from trackma import utils
|
|
25
|
-
|
|
26
|
-
class libhb(lib):
|
|
27
|
-
"""
|
|
28
|
-
API class to communicate with Hummingbird
|
|
29
|
-
Should inherit a base library interface.
|
|
30
|
-
|
|
31
|
-
Website: https://hummingbird.me/
|
|
32
|
-
API documentation:
|
|
33
|
-
Designed by:
|
|
34
|
-
|
|
35
|
-
"""
|
|
36
|
-
name = 'libhb'
|
|
37
|
-
|
|
38
|
-
username = '' # TODO Must be filled by check_credentials
|
|
39
|
-
auth = ''
|
|
40
|
-
logged_in = False
|
|
41
|
-
|
|
42
|
-
api_info = { 'name': 'Hummingbird', 'shortname': 'hb', 'version': 'v0.2', 'merge': False }
|
|
43
|
-
|
|
44
|
-
default_mediatype = 'anime'
|
|
45
|
-
mediatypes = dict()
|
|
46
|
-
mediatypes['anime'] = {
|
|
47
|
-
'has_progress': True,
|
|
48
|
-
'can_add': True,
|
|
49
|
-
'can_delete': True,
|
|
50
|
-
'can_score': True,
|
|
51
|
-
'can_status': True,
|
|
52
|
-
'can_update': True,
|
|
53
|
-
'can_play': True,
|
|
54
|
-
'status_start': 'currently-watching',
|
|
55
|
-
'status_finish': 'completed',
|
|
56
|
-
'statuses': ['currently-watching', 'completed', 'on-hold', 'dropped', 'plan-to-watch'],
|
|
57
|
-
'statuses_dict': { 'currently-watching': 'Watching', 'completed': 'Completed', 'on-hold': 'On Hold', 'dropped': 'Dropped', 'plan-to-watch': 'Plan to Watch' },
|
|
58
|
-
'score_max': 5,
|
|
59
|
-
'score_step': 0.5,
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
url = "https://hummingbird.me/api/v1"
|
|
63
|
-
|
|
64
|
-
status_translate = {'Currently Airing': utils.STATUS_AIRING,
|
|
65
|
-
'Finished Airing': utils.STATUS_FINISHED,
|
|
66
|
-
'Not Yet Aired': utils.STATUS_NOTYET}
|
|
67
|
-
|
|
68
|
-
def __init__(self, messenger, account, userconfig):
|
|
69
|
-
"""Initializes the useragent through credentials."""
|
|
70
|
-
super(libhb, self).__init__(messenger, account, userconfig)
|
|
71
|
-
|
|
72
|
-
self.username = account['username']
|
|
73
|
-
self.password = account['password']
|
|
74
|
-
|
|
75
|
-
# Build opener with the mashape API key
|
|
76
|
-
self.opener = urllib.request.build_opener()
|
|
77
|
-
|
|
78
|
-
def _request(self, url, get=None, post=None):
|
|
79
|
-
if get:
|
|
80
|
-
url += "?%s" % urllib.parse.urlencode(get)
|
|
81
|
-
if post:
|
|
82
|
-
post = urllib.parse.urlencode(post).encode('utf-8')
|
|
83
|
-
|
|
84
|
-
try:
|
|
85
|
-
return self.opener.open(self.url + url, post, 10)
|
|
86
|
-
except urllib.request.HTTPError as e:
|
|
87
|
-
if e.code == 401:
|
|
88
|
-
raise utils.APIError("Incorrect credentials.")
|
|
89
|
-
else:
|
|
90
|
-
raise utils.APIError("Connection error: %s" % e)
|
|
91
|
-
except urllib.request.URLError as e:
|
|
92
|
-
raise utils.APIError("URL error: %s" % e)
|
|
93
|
-
|
|
94
|
-
def check_credentials(self):
|
|
95
|
-
"""Checks if credentials are correct; returns True or False."""
|
|
96
|
-
if self.logged_in:
|
|
97
|
-
return True # Already logged in
|
|
98
|
-
|
|
99
|
-
self.msg.info(self.name, 'Logging in...')
|
|
100
|
-
|
|
101
|
-
response = self._request( "/users/authenticate", post={'username': self.username, 'password': self.password} ).read().decode('utf-8')
|
|
102
|
-
self.auth = response.strip('"')
|
|
103
|
-
self._set_userconfig('username', self.username)
|
|
104
|
-
self.logged_in = True
|
|
105
|
-
return True
|
|
106
|
-
|
|
107
|
-
def fetch_list(self):
|
|
108
|
-
"""Queries the full list from the remote server.
|
|
109
|
-
Returns the list if successful, False otherwise."""
|
|
110
|
-
self.check_credentials()
|
|
111
|
-
self.msg.info(self.name, 'Downloading list...')
|
|
112
|
-
|
|
113
|
-
try:
|
|
114
|
-
data = self._request( "/users/%s/library" % self.username, get={'auth_token': self.auth} )
|
|
115
|
-
shows = json.loads(data.read().decode('utf-8'))
|
|
116
|
-
|
|
117
|
-
showlist = dict()
|
|
118
|
-
infolist = list()
|
|
119
|
-
|
|
120
|
-
for show in shows:
|
|
121
|
-
showid = show['anime']['id']
|
|
122
|
-
status = show['anime']['status']
|
|
123
|
-
rating = show['rating']['value']
|
|
124
|
-
epCount = show['anime']['episode_count']
|
|
125
|
-
alt_titles = []
|
|
126
|
-
|
|
127
|
-
if show['anime']['alternate_title'] is not None:
|
|
128
|
-
alt_titles.append(show['anime']['alternate_title'])
|
|
129
|
-
showlist[showid] = utils.show()
|
|
130
|
-
showlist[showid].update({
|
|
131
|
-
'id': showid,
|
|
132
|
-
'title': show['anime']['title'] or show['anime']['alternate_title'] or "",
|
|
133
|
-
'status': self.status_translate[status],
|
|
134
|
-
'start_date': self._str2date( show['anime']['started_airing'] ),
|
|
135
|
-
'end_date': self._str2date( show['anime']['finished_airing'] ),
|
|
136
|
-
'my_progress': show['episodes_watched'],
|
|
137
|
-
'my_score': float(rating) if rating is not None else 0.0,
|
|
138
|
-
'aliases': alt_titles,
|
|
139
|
-
'my_status': show['status'],
|
|
140
|
-
'total': int(epCount) if epCount is not None else 0,
|
|
141
|
-
'image': show['anime']['cover_image'],
|
|
142
|
-
'url': str("https://hummingbird.me/%s/%d" % (self.mediatype, showid)),
|
|
143
|
-
})
|
|
144
|
-
info = self._parse_info(show['anime'])
|
|
145
|
-
infolist.append(info)
|
|
146
|
-
|
|
147
|
-
self._emit_signal('show_info_changed', infolist)
|
|
148
|
-
return showlist
|
|
149
|
-
except urllib.request.HTTPError as e:
|
|
150
|
-
raise utils.APIError("Error getting list.")
|
|
151
|
-
|
|
152
|
-
def add_show(self, item):
|
|
153
|
-
"""Adds a new show in the server"""
|
|
154
|
-
self.update_show(item)
|
|
155
|
-
|
|
156
|
-
def update_show(self, item):
|
|
157
|
-
"""Sends a show update to the server"""
|
|
158
|
-
self.check_credentials()
|
|
159
|
-
self.msg.info(self.name, "Updating show %s..." % item['title'])
|
|
160
|
-
|
|
161
|
-
# Send the POST data to the Hummingbird API
|
|
162
|
-
values = {'auth_token': self.auth}
|
|
163
|
-
|
|
164
|
-
# Update necessary keys
|
|
165
|
-
if 'my_progress' in item.keys():
|
|
166
|
-
values['episodes_watched'] = item['my_progress']
|
|
167
|
-
if 'my_status' in item.keys():
|
|
168
|
-
values['status'] = item['my_status']
|
|
169
|
-
if 'my_score' in item.keys():
|
|
170
|
-
values['sane_rating_update'] = item['my_score']
|
|
171
|
-
|
|
172
|
-
try:
|
|
173
|
-
self._request("/libraries/%s" % item['id'], post=values)
|
|
174
|
-
except urllib.request.HTTPError as e:
|
|
175
|
-
raise utils.APIError('Error updating: ' + str(e.code))
|
|
176
|
-
|
|
177
|
-
def delete_show(self, item):
|
|
178
|
-
"""Sends a show delete to the server"""
|
|
179
|
-
self.check_credentials()
|
|
180
|
-
self.msg.info(self.name, "Deleting show %s..." % item['title'])
|
|
181
|
-
|
|
182
|
-
values = {'auth_token': self.auth}
|
|
183
|
-
try:
|
|
184
|
-
self._request("/libraries/%s/remove" % item['id'], post=values)
|
|
185
|
-
except urllib.request.HTTPError as e:
|
|
186
|
-
raise utils.APIError('Error deleting: ' + str(e.code))
|
|
187
|
-
|
|
188
|
-
def search(self, query):
|
|
189
|
-
self.msg.info(self.name, "Searching for %s..." % query)
|
|
190
|
-
|
|
191
|
-
values = {'query': query}
|
|
192
|
-
try:
|
|
193
|
-
data = self._request("/search/anime", get=values)
|
|
194
|
-
shows = json.loads(data.read().decode('utf-8'))
|
|
195
|
-
|
|
196
|
-
infolist = []
|
|
197
|
-
for show in shows:
|
|
198
|
-
info = self._parse_info(show)
|
|
199
|
-
info['my_status'] = 'currently-watching' # TODO : Default to watching; this should be changeable
|
|
200
|
-
infolist.append(info)
|
|
201
|
-
|
|
202
|
-
self._emit_signal('show_info_changed', infolist)
|
|
203
|
-
|
|
204
|
-
if not infolist:
|
|
205
|
-
raise utils.APIError('No results.')
|
|
206
|
-
|
|
207
|
-
return infolist
|
|
208
|
-
except urllib.request.HTTPError as e:
|
|
209
|
-
raise utils.APIError('Error searching: ' + str(e.code))
|
|
210
|
-
|
|
211
|
-
def _str2date(self, string):
|
|
212
|
-
if string != '0000-00-00':
|
|
213
|
-
try:
|
|
214
|
-
return datetime.datetime.strptime(string, "%Y-%m-%d")
|
|
215
|
-
except:
|
|
216
|
-
return None # Ignore date if it's invalid
|
|
217
|
-
else:
|
|
218
|
-
return None
|
|
219
|
-
|
|
220
|
-
def _parse_info(self, show):
|
|
221
|
-
info = utils.show()
|
|
222
|
-
alt_titles = []
|
|
223
|
-
if show['alternate_title'] is not None:
|
|
224
|
-
alt_titles.append(show['alternate_title'])
|
|
225
|
-
info.update({
|
|
226
|
-
'id': show['id'],
|
|
227
|
-
'title': show['title'] or show['alternate_title'] or "",
|
|
228
|
-
'status': self.status_translate[show['status']],
|
|
229
|
-
'image': show['cover_image'],
|
|
230
|
-
'url': show['url'],
|
|
231
|
-
'aliases': alt_titles,
|
|
232
|
-
'extra': [
|
|
233
|
-
('Alternate title', show['alternate_title']),
|
|
234
|
-
('Show type', show['show_type']),
|
|
235
|
-
('Synopsis', show['synopsis']),
|
|
236
|
-
('Status', show['status']),
|
|
237
|
-
]
|
|
238
|
-
})
|
|
239
|
-
return info
|
trackma/lib/libmelative.py
DELETED
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
# This file is part of Trackma.
|
|
2
|
-
#
|
|
3
|
-
# This program is free software: you can redistribute it and/or modify
|
|
4
|
-
# it under the terms of the GNU General Public License as published by
|
|
5
|
-
# the Free Software Foundation, either version 3 of the License, or
|
|
6
|
-
# (at your option) any later version.
|
|
7
|
-
#
|
|
8
|
-
# This program is distributed in the hope that it will be useful,
|
|
9
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
-
# GNU General Public License for more details.
|
|
12
|
-
#
|
|
13
|
-
# You should have received a copy of the GNU General Public License
|
|
14
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
15
|
-
#
|
|
16
|
-
|
|
17
|
-
import urllib.parse
|
|
18
|
-
import urllib.request
|
|
19
|
-
import json
|
|
20
|
-
|
|
21
|
-
from trackma.lib.lib import lib
|
|
22
|
-
from trackma import utils
|
|
23
|
-
|
|
24
|
-
class libmelative(lib):
|
|
25
|
-
"""
|
|
26
|
-
API class to communiate with Melative.
|
|
27
|
-
|
|
28
|
-
http://www.melative.com
|
|
29
|
-
|
|
30
|
-
"""
|
|
31
|
-
name = 'libmelative'
|
|
32
|
-
|
|
33
|
-
api_info = { 'name': 'Melative', 'shortname': 'melative', 'version': 'v0.1', 'merge': False }
|
|
34
|
-
|
|
35
|
-
mediatypes = dict()
|
|
36
|
-
|
|
37
|
-
# All mediatypes share the same statuses so we'll reuse them
|
|
38
|
-
statuses = [1, 2, 3, 4, 6]
|
|
39
|
-
statuses_dict = { 1: 'Current', 2: 'Complete', 3: 'Hold', 4: 'Dropped', 6: 'Wishlisted' }
|
|
40
|
-
|
|
41
|
-
default_mediatype = 'anime'
|
|
42
|
-
mediatypes['anime'] = {
|
|
43
|
-
'has_progress': True,
|
|
44
|
-
'can_score': True,
|
|
45
|
-
'can_status': True,
|
|
46
|
-
'can_update': True,
|
|
47
|
-
'can_play': True,
|
|
48
|
-
'statuses': statuses,
|
|
49
|
-
'statuses_dict': statuses_dict,
|
|
50
|
-
'segment_type': 'Episode',
|
|
51
|
-
'score_max': 10,
|
|
52
|
-
'score_step': 0.1,
|
|
53
|
-
}
|
|
54
|
-
mediatypes['manga'] = {
|
|
55
|
-
'has_progress': True,
|
|
56
|
-
'can_score': True,
|
|
57
|
-
'can_status': True,
|
|
58
|
-
'can_update': True,
|
|
59
|
-
'can_play': False,
|
|
60
|
-
'statuses': statuses,
|
|
61
|
-
'statuses_dict': statuses_dict,
|
|
62
|
-
'segment_type': 'Chapter',
|
|
63
|
-
'score_max': 10,
|
|
64
|
-
'score_step': 0.1,
|
|
65
|
-
}
|
|
66
|
-
mediatypes['vn'] = {
|
|
67
|
-
'has_progress': False,
|
|
68
|
-
'can_score': True,
|
|
69
|
-
'can_status': True,
|
|
70
|
-
'can_update': True,
|
|
71
|
-
'can_play': False,
|
|
72
|
-
'statuses': statuses,
|
|
73
|
-
'statuses_dict': statuses_dict,
|
|
74
|
-
'segment_type': 'Chapter',
|
|
75
|
-
'score_max': 10,
|
|
76
|
-
'score_step': 0.1,
|
|
77
|
-
}
|
|
78
|
-
mediatypes['lightnovel'] = {
|
|
79
|
-
'has_progress': True,
|
|
80
|
-
'can_score': True,
|
|
81
|
-
'can_status': True,
|
|
82
|
-
'can_update': True,
|
|
83
|
-
'can_play': False,
|
|
84
|
-
'statuses': statuses,
|
|
85
|
-
'statuses_dict': statuses_dict,
|
|
86
|
-
'segment_type': 'Chapter',
|
|
87
|
-
'score_max': 10,
|
|
88
|
-
'score_step': 0.1,
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
def __init__(self, messenger, account, userconfig):
|
|
92
|
-
"""Initializes the useragent through credentials."""
|
|
93
|
-
super(libmelative, self).__init__(messenger, account, userconfig)
|
|
94
|
-
|
|
95
|
-
self.username = account['username']
|
|
96
|
-
|
|
97
|
-
self.password_mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()
|
|
98
|
-
self.password_mgr.add_password("Melative", "melative.com:80", account['username'], account['password']);
|
|
99
|
-
|
|
100
|
-
self.handler = urllib.request.HTTPBasicAuthHandler(self.password_mgr)
|
|
101
|
-
self.opener = urllib.request.build_opener(self.handler)
|
|
102
|
-
|
|
103
|
-
urllib.request.install_opener(self.opener)
|
|
104
|
-
|
|
105
|
-
def check_credentials(self):
|
|
106
|
-
self.msg.info(self.name, 'Logging in...')
|
|
107
|
-
|
|
108
|
-
try:
|
|
109
|
-
response = self.opener.open("http://melative.com/api/account/verify_credentials.json")
|
|
110
|
-
self.logged_in = True
|
|
111
|
-
|
|
112
|
-
# Parse user information
|
|
113
|
-
data = json.loads(response.read().decode('utf-8'))
|
|
114
|
-
|
|
115
|
-
self.username = data['name']
|
|
116
|
-
self.userid = data['id']
|
|
117
|
-
|
|
118
|
-
return True
|
|
119
|
-
except urllib.request.HTTPError as e:
|
|
120
|
-
raise utils.APIError("Incorrect credentials.")
|
|
121
|
-
|
|
122
|
-
def fetch_list(self):
|
|
123
|
-
self.check_credentials()
|
|
124
|
-
self.msg.info(self.name, 'Downloading list...')
|
|
125
|
-
|
|
126
|
-
# Get a JSON list from API
|
|
127
|
-
response = self.opener.open("http://melative.com/api/library.json?user={0}&context_type={1}".format(self.username, self.mediatype))
|
|
128
|
-
data = json.loads(response.read().decode('utf-8'))
|
|
129
|
-
|
|
130
|
-
# Load data from the JSON stream into a parsed dictionary
|
|
131
|
-
statuses = self.media_info()['statuses_dict']
|
|
132
|
-
itemlist = dict()
|
|
133
|
-
for record in data['library']:
|
|
134
|
-
entity = record['entity']
|
|
135
|
-
segment = record['segment']
|
|
136
|
-
itemid = int(entity['id'])
|
|
137
|
-
|
|
138
|
-
# use appropiate number for the show state
|
|
139
|
-
_status = 0
|
|
140
|
-
for k, v in statuses.items():
|
|
141
|
-
if v.lower() == record['state']:
|
|
142
|
-
_status = k
|
|
143
|
-
|
|
144
|
-
# use show length if available
|
|
145
|
-
try:
|
|
146
|
-
_total = int(entity['length'])
|
|
147
|
-
except TypeError:
|
|
148
|
-
_total = 0
|
|
149
|
-
|
|
150
|
-
# use show progress if needed
|
|
151
|
-
if self.mediatypes[self.mediatype]['has_progress']:
|
|
152
|
-
_progress = int(segment['name'])
|
|
153
|
-
else:
|
|
154
|
-
_progress = 0
|
|
155
|
-
|
|
156
|
-
show = utils.show()
|
|
157
|
-
show['id'] = itemid
|
|
158
|
-
show['title'] = entity['aliases'][0]
|
|
159
|
-
show['my_status'] = _status
|
|
160
|
-
show['my_score'] = int(record['rating'] or 0)
|
|
161
|
-
show['my_progress'] =_progress
|
|
162
|
-
show['total'] = _total
|
|
163
|
-
show['image'] = entity['image_url']
|
|
164
|
-
show['status'] = 0 #placeholder
|
|
165
|
-
|
|
166
|
-
itemlist[itemid] = show
|
|
167
|
-
|
|
168
|
-
return itemlist
|
|
169
|
-
|
|
170
|
-
#except urllib.request.HTTPError as e:
|
|
171
|
-
# raise utils.APIError("Error getting list. %s" % e)
|
|
172
|
-
|
|
173
|
-
def update_show(self, item):
|
|
174
|
-
self.check_credentials()
|
|
175
|
-
self.msg.info(self.name, 'Updating show %s...' % item['title'])
|
|
176
|
-
|
|
177
|
-
changes = dict()
|
|
178
|
-
if self.media_info()['has_progress'] and 'my_progress' in item.keys():
|
|
179
|
-
# We need to update the segment, so we call api/scrobble
|
|
180
|
-
#values = dict()
|
|
181
|
-
#values = {'attribute_type': _self.media_info['segment_type'],
|
|
182
|
-
# 'attribute_name': item['my_progress']}
|
|
183
|
-
#data = urllib.parse.urlencode(values)
|
|
184
|
-
#
|
|
185
|
-
#try:
|
|
186
|
-
# reponse = self.opener.open("http://melative.com/api/scrobble.json", data.encode('utf-8'))
|
|
187
|
-
#except urllib.request.HTTPError as e:
|
|
188
|
-
# raise utils.APIError("Error scrobbling: " + str(e.code))
|
|
189
|
-
changes['segment'] = "%s|%d" % (self.media_info()['segment_type'], item['my_progress'] )
|
|
190
|
-
|
|
191
|
-
if 'my_status' in item.keys():
|
|
192
|
-
changes['state'] = self.statuses_dict[item['my_status']]
|
|
193
|
-
|
|
194
|
-
if 'my_score' in item.keys():
|
|
195
|
-
changes['rating'] = item['my_score']
|
|
196
|
-
|
|
197
|
-
data = urllib.parse.urlencode(changes)
|
|
198
|
-
|
|
199
|
-
try:
|
|
200
|
-
response = self.opener.open("http://melative.com/api/scrobble.json", data.encode('utf-8'))
|
|
201
|
-
except urllib.request.HTTPError as e:
|
|
202
|
-
raise utils.APIError("Error updating: " + str(e.code))
|
|
203
|
-
|
|
204
|
-
return True
|