trackma 0.4__py2.7.egg → 0.5__py2.7.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 +2 -0
- trackma/__init__.pyc +0 -0
- trackma/accounts.py +36 -1
- trackma/accounts.pyc +0 -0
- trackma/data/shikimori.jpg +0 -0
- trackma/data.py +33 -20
- trackma/data.pyc +0 -0
- trackma/engine.py +82 -11
- trackma/engine.pyc +0 -0
- trackma/extras/AnimeInfoExtractor.pyc +0 -0
- trackma/extras/__init__.pyc +0 -0
- trackma/extras/plex.pyc +0 -0
- trackma/lib/__init__.pyc +0 -0
- trackma/lib/lib.pyc +0 -0
- trackma/lib/libanilist.py +65 -17
- trackma/lib/libanilist.pyc +0 -0
- trackma/lib/libhb.py +4 -5
- trackma/lib/libhb.pyc +0 -0
- trackma/lib/libmal.py +10 -7
- trackma/lib/libmal.pyc +0 -0
- trackma/lib/libmelative.py +1 -1
- trackma/lib/libmelative.pyc +0 -0
- trackma/lib/libshikimori.py +338 -0
- trackma/lib/libshikimori.pyc +0 -0
- trackma/lib/libvndb.py +1 -0
- trackma/lib/libvndb.pyc +0 -0
- trackma/messenger.pyc +0 -0
- trackma/tracker.py +64 -17
- trackma/tracker.pyc +0 -0
- trackma/ui/__init__.pyc +0 -0
- trackma/ui/cli.py +191 -70
- trackma/ui/cli.pyc +0 -0
- trackma/ui/curses.py +14 -3
- trackma/ui/curses.pyc +0 -0
- trackma/ui/gtkui.py +341 -110
- trackma/ui/gtkui.pyc +0 -0
- trackma/ui/qtui.py +1243 -327
- trackma/ui/qtui.pyc +0 -0
- trackma/utils.py +118 -38
- trackma/utils.pyc +0 -0
EGG-INFO/PKG-INFO
CHANGED
EGG-INFO/SOURCES.txt
CHANGED
|
@@ -17,6 +17,7 @@ trackma/data/hb.jpg
|
|
|
17
17
|
trackma/data/icon.png
|
|
18
18
|
trackma/data/mal.jpg
|
|
19
19
|
trackma/data/melative.jpg
|
|
20
|
+
trackma/data/shikimori.jpg
|
|
20
21
|
trackma/data/vndb.jpg
|
|
21
22
|
trackma/extras/AnimeInfoExtractor.py
|
|
22
23
|
trackma/extras/__init__.py
|
|
@@ -27,6 +28,7 @@ trackma/lib/libanilist.py
|
|
|
27
28
|
trackma/lib/libhb.py
|
|
28
29
|
trackma/lib/libmal.py
|
|
29
30
|
trackma/lib/libmelative.py
|
|
31
|
+
trackma/lib/libshikimori.py
|
|
30
32
|
trackma/lib/libvndb.py
|
|
31
33
|
trackma/ui/__init__.py
|
|
32
34
|
trackma/ui/cli.py
|
trackma/__init__.pyc
CHANGED
|
Binary file
|
trackma/accounts.py
CHANGED
|
@@ -24,13 +24,16 @@ class AccountManager(object):
|
|
|
24
24
|
self.accounts = cPickle.load(f)
|
|
25
25
|
|
|
26
26
|
def _save(self):
|
|
27
|
+
is_new = not utils.file_exists(self.filename)
|
|
27
28
|
with open(self.filename, 'wb') as f:
|
|
29
|
+
if is_new:
|
|
30
|
+
utils.change_permissions(self.filename, 0o600)
|
|
28
31
|
cPickle.dump(self.accounts, f)
|
|
29
32
|
|
|
30
33
|
def add_account(self, username, password, api):
|
|
31
34
|
"""
|
|
32
35
|
Registers a new account with the specified
|
|
33
|
-
*username*, *password
|
|
36
|
+
*username*, *password*, and *api*.
|
|
34
37
|
|
|
35
38
|
The *api* must be one of the available APIs
|
|
36
39
|
found in the utils.available_libs dict.
|
|
@@ -55,6 +58,29 @@ class AccountManager(object):
|
|
|
55
58
|
self.accounts['next'] += 1
|
|
56
59
|
self._save()
|
|
57
60
|
|
|
61
|
+
def edit_account(self, num, username, password, api, friends=[]):
|
|
62
|
+
"""
|
|
63
|
+
Updates data for account *num* with the specified
|
|
64
|
+
*username*, *password*, and *api*.
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
available_libs = utils.available_libs.keys()
|
|
68
|
+
|
|
69
|
+
if not username:
|
|
70
|
+
raise utils.AccountError('Empty username.')
|
|
71
|
+
if not password:
|
|
72
|
+
raise utils.AccountError('Empty password.')
|
|
73
|
+
if api not in available_libs:
|
|
74
|
+
raise utils.AccountError('That API doesn\'t exist.')
|
|
75
|
+
|
|
76
|
+
account = {'username': username,
|
|
77
|
+
'password': password,
|
|
78
|
+
'api': api,
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
self.accounts['accounts'][num].update(account)
|
|
82
|
+
self._save()
|
|
83
|
+
|
|
58
84
|
def delete_account(self, num):
|
|
59
85
|
"""
|
|
60
86
|
Deletes the account number **num**.
|
|
@@ -68,6 +94,15 @@ class AccountManager(object):
|
|
|
68
94
|
|
|
69
95
|
self._save()
|
|
70
96
|
|
|
97
|
+
def purge_account(self, num):
|
|
98
|
+
"""
|
|
99
|
+
Renames stale cache files for account number **num**.
|
|
100
|
+
"""
|
|
101
|
+
account = self.accounts['accounts'][num]
|
|
102
|
+
userfolder = "%s.%s" % (account['username'], account['api'])
|
|
103
|
+
utils.make_dir(userfolder + '.old')
|
|
104
|
+
utils.regex_rename_files('(.*.queue)|(.*.info)|(.*.list)|(.*.meta)', userfolder, userfolder + '.old')
|
|
105
|
+
|
|
71
106
|
def get_account(self, num):
|
|
72
107
|
"""
|
|
73
108
|
Returns the account dict **num**.
|
trackma/accounts.pyc
CHANGED
|
Binary file
|
|
Binary file
|
trackma/data.py
CHANGED
|
@@ -37,7 +37,7 @@ class Data(object):
|
|
|
37
37
|
|
|
38
38
|
"""
|
|
39
39
|
name = 'Data'
|
|
40
|
-
version =
|
|
40
|
+
version = 4
|
|
41
41
|
|
|
42
42
|
msg = None
|
|
43
43
|
api = None
|
|
@@ -51,6 +51,7 @@ class Data(object):
|
|
|
51
51
|
|
|
52
52
|
signals = {
|
|
53
53
|
'show_synced': None,
|
|
54
|
+
'sync_complete': None,
|
|
54
55
|
'queue_changed': None,
|
|
55
56
|
}
|
|
56
57
|
|
|
@@ -100,11 +101,8 @@ class Data(object):
|
|
|
100
101
|
self.api.connect_signal('userconfig_changed', self.userconfig_update)
|
|
101
102
|
|
|
102
103
|
def _emit_signal(self, signal, *args):
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
self.signals[signal](*args)
|
|
106
|
-
except KeyError:
|
|
107
|
-
raise Exception("Call to undefined signal.")
|
|
104
|
+
if self.signals[signal]:
|
|
105
|
+
self.signals[signal](*args)
|
|
108
106
|
|
|
109
107
|
def connect_signal(self, signal, callback):
|
|
110
108
|
try:
|
|
@@ -135,7 +133,8 @@ class Data(object):
|
|
|
135
133
|
if self._queue_exists():
|
|
136
134
|
self._load_queue()
|
|
137
135
|
|
|
138
|
-
if self._info_exists():
|
|
136
|
+
if self._info_exists() and self.meta.get('version') == self.version:
|
|
137
|
+
# Load info cache only if we're on the same database version
|
|
139
138
|
self._load_info()
|
|
140
139
|
|
|
141
140
|
# If there is a list cache, load from it
|
|
@@ -274,7 +273,11 @@ class Data(object):
|
|
|
274
273
|
|
|
275
274
|
if not exists:
|
|
276
275
|
# Create queue item and append it
|
|
277
|
-
item = {'id': show['id'],
|
|
276
|
+
item = {'id': show['id'],
|
|
277
|
+
'my_id': show['my_id'],
|
|
278
|
+
'action': 'update',
|
|
279
|
+
'title': show['title'],
|
|
280
|
+
}
|
|
278
281
|
item[key] = value
|
|
279
282
|
self.queue.append(item)
|
|
280
283
|
|
|
@@ -359,41 +362,51 @@ class Data(object):
|
|
|
359
362
|
# raise utils.DataError("Can't process queue, will leave unsynced. Reason: %s" % e.message)
|
|
360
363
|
|
|
361
364
|
# Run through queue
|
|
365
|
+
items_processed = []
|
|
362
366
|
for i in xrange(len(self.queue)):
|
|
363
|
-
|
|
364
|
-
showid =
|
|
367
|
+
item = self.queue.pop(0)
|
|
368
|
+
showid = item['id']
|
|
369
|
+
|
|
370
|
+
try:
|
|
371
|
+
show = self.showlist[showid]
|
|
372
|
+
except KeyError:
|
|
373
|
+
show = None
|
|
365
374
|
|
|
366
375
|
try:
|
|
367
376
|
# Call the API to do the requested operation
|
|
368
|
-
operation =
|
|
377
|
+
operation = item.get('action')
|
|
369
378
|
if operation == 'add':
|
|
370
|
-
self.api.add_show(
|
|
379
|
+
my_id = self.api.add_show(item)
|
|
380
|
+
|
|
381
|
+
if my_id:
|
|
382
|
+
show['my_id'] = my_id
|
|
371
383
|
elif operation == 'update':
|
|
372
|
-
self.api.update_show(
|
|
384
|
+
self.api.update_show(item)
|
|
373
385
|
elif operation == 'delete':
|
|
374
|
-
self.api.delete_show(
|
|
386
|
+
self.api.delete_show(item)
|
|
375
387
|
else:
|
|
376
|
-
self.msg.warn(self.name, "Unknown operation in queue, skipping...")
|
|
388
|
+
self.msg.warn(self.name, "Unknown operation in queue (%s), skipping..." % repr(operation))
|
|
377
389
|
|
|
378
390
|
if self.showlist.get(showid):
|
|
379
391
|
self.showlist[showid]['queued'] = False
|
|
380
|
-
self._emit_signal('show_synced',
|
|
392
|
+
self._emit_signal('show_synced', show, item)
|
|
381
393
|
|
|
394
|
+
items_processed.append((show, item))
|
|
382
395
|
self._emit_signal('queue_changed', len(self.queue))
|
|
383
396
|
except utils.APIError, e:
|
|
384
|
-
self.msg.warn(self.name, "Can't process %s, will leave unsynced." %
|
|
397
|
+
self.msg.warn(self.name, "Can't process %s, will leave unsynced." % item['title'])
|
|
385
398
|
self.msg.debug(self.name, "Info: %s" % e.message)
|
|
386
|
-
self.queue.append(
|
|
399
|
+
self.queue.append(item)
|
|
387
400
|
except NotImplementedError:
|
|
388
401
|
self.msg.warn(self.name, "Operation not implemented in API. Skipping...")
|
|
389
|
-
self.queue.append(
|
|
402
|
+
self.queue.append(item)
|
|
390
403
|
#except TypeError:
|
|
391
404
|
# self.msg.warn(self.name, "%s not in list, unexpected. Not changing queued status." % showid)
|
|
392
405
|
|
|
393
406
|
self.api.logout()
|
|
394
407
|
self._save_cache()
|
|
395
408
|
self._save_queue()
|
|
396
|
-
|
|
409
|
+
self._emit_signal('sync_complete', items_processed)
|
|
397
410
|
else:
|
|
398
411
|
self.msg.debug(self.name, 'No items in queue.')
|
|
399
412
|
|
trackma/data.pyc
CHANGED
|
Binary file
|
trackma/engine.py
CHANGED
|
@@ -23,7 +23,7 @@ import threading
|
|
|
23
23
|
import difflib
|
|
24
24
|
import time
|
|
25
25
|
import datetime
|
|
26
|
-
import
|
|
26
|
+
import random
|
|
27
27
|
import shlex
|
|
28
28
|
|
|
29
29
|
import messenger
|
|
@@ -55,6 +55,7 @@ class Engine:
|
|
|
55
55
|
msg = None
|
|
56
56
|
loaded = False
|
|
57
57
|
playing = False
|
|
58
|
+
hooks_available = False
|
|
58
59
|
|
|
59
60
|
name = 'Engine'
|
|
60
61
|
|
|
@@ -64,6 +65,7 @@ class Engine:
|
|
|
64
65
|
'score_changed': None,
|
|
65
66
|
'status_changed': None,
|
|
66
67
|
'show_synced': None,
|
|
68
|
+
'sync_complete': None,
|
|
67
69
|
'queue_changed': None,
|
|
68
70
|
'playing': None,
|
|
69
71
|
'prompt_for_update': None, }
|
|
@@ -94,17 +96,34 @@ class Engine:
|
|
|
94
96
|
except IOError:
|
|
95
97
|
raise utils.EngineFatal("Couldn't open config file.")
|
|
96
98
|
|
|
99
|
+
# Load hook file
|
|
100
|
+
if os.path.exists(utils.get_root_filename('hook.py')):
|
|
101
|
+
import sys
|
|
102
|
+
sys.path[0:0] = [utils.get_root()]
|
|
103
|
+
try:
|
|
104
|
+
self.msg.info(self.name, "Importing user hooks (hook.py)...")
|
|
105
|
+
global hook
|
|
106
|
+
import hook
|
|
107
|
+
self.hooks_available = True
|
|
108
|
+
except ImportError:
|
|
109
|
+
self.msg.warn(self.name, "Error importing hooks.")
|
|
110
|
+
del sys.path[0]
|
|
111
|
+
|
|
97
112
|
def _init_data_handler(self, mediatype=None):
|
|
98
113
|
# Create data handler
|
|
99
114
|
self.data_handler = data.Data(self.msg, self.config, self.account, mediatype)
|
|
100
115
|
self.data_handler.connect_signal('show_synced', self._data_show_synced)
|
|
116
|
+
self.data_handler.connect_signal('sync_complete', self._data_sync_complete)
|
|
101
117
|
self.data_handler.connect_signal('queue_changed', self._data_queue_changed)
|
|
102
118
|
|
|
103
119
|
# Record the API details
|
|
104
120
|
(self.api_info, self.mediainfo) = self.data_handler.get_api_info()
|
|
105
121
|
|
|
106
|
-
def _data_show_synced(self, show):
|
|
107
|
-
self._emit_signal('show_synced', show)
|
|
122
|
+
def _data_show_synced(self, show, changes):
|
|
123
|
+
self._emit_signal('show_synced', show, changes)
|
|
124
|
+
|
|
125
|
+
def _data_sync_complete(self, items):
|
|
126
|
+
self._emit_signal('sync_complete', items)
|
|
108
127
|
|
|
109
128
|
def _data_queue_changed(self, queue):
|
|
110
129
|
self._emit_signal('queue_changed', queue)
|
|
@@ -124,8 +143,12 @@ class Engine:
|
|
|
124
143
|
try:
|
|
125
144
|
if self.signals[signal]:
|
|
126
145
|
self.signals[signal](*args)
|
|
127
|
-
|
|
128
|
-
|
|
146
|
+
if self.hooks_available:
|
|
147
|
+
method = getattr(hook, signal)
|
|
148
|
+
self.msg.debug(self.name, "Calling hook %s..." % signal)
|
|
149
|
+
method(self, *args)
|
|
150
|
+
except AttributeError:
|
|
151
|
+
pass
|
|
129
152
|
|
|
130
153
|
def _get_tracker_list(self, filter_num=None):
|
|
131
154
|
tracker_list = []
|
|
@@ -267,7 +290,7 @@ class Engine:
|
|
|
267
290
|
showdict = self.data_handler.get()
|
|
268
291
|
# Do title lookup, slower
|
|
269
292
|
for k, show in showdict.iteritems():
|
|
270
|
-
if show['title'] == pattern:
|
|
293
|
+
if show['title'].encode('utf-8') == pattern:
|
|
271
294
|
return show
|
|
272
295
|
raise utils.EngineError("Show not found.")
|
|
273
296
|
|
|
@@ -349,7 +372,7 @@ class Engine:
|
|
|
349
372
|
# Get the show info
|
|
350
373
|
show = self.get_show_info(showid)
|
|
351
374
|
# More checks
|
|
352
|
-
if show['total'] and newep > show['total']:
|
|
375
|
+
if (show['total'] and newep > show['total']) or newep < 0:
|
|
353
376
|
raise utils.EngineError('Episode out of limits.')
|
|
354
377
|
if show['my_progress'] == newep:
|
|
355
378
|
raise utils.EngineError("Show already at episode %d" % newep)
|
|
@@ -513,6 +536,30 @@ class Engine:
|
|
|
513
536
|
|
|
514
537
|
return show
|
|
515
538
|
|
|
539
|
+
def set_tags(self, showid, newtags):
|
|
540
|
+
"""
|
|
541
|
+
Updates the tags of the specified **showid** to **newtags**
|
|
542
|
+
and queues the list update for the next sync.
|
|
543
|
+
"""
|
|
544
|
+
# Check if operation is supported by the API
|
|
545
|
+
if 'can_tag' not in self.mediainfo or not self.mediainfo.get('can_tag'):
|
|
546
|
+
raise utils.EngineError('Operation not supported by API.')
|
|
547
|
+
|
|
548
|
+
# Get the show and update it
|
|
549
|
+
show = self.get_show_info(showid)
|
|
550
|
+
# More checks
|
|
551
|
+
if show['my_tags'] == newtags:
|
|
552
|
+
raise utils.EngineError("Tags already %s" % newtags)
|
|
553
|
+
|
|
554
|
+
# Change score
|
|
555
|
+
self.msg.info(self.name, "Updating show %s to tags '%s'..." % (show['title'], newtags))
|
|
556
|
+
self.data_handler.queue_update(show, 'my_tags', newtags)
|
|
557
|
+
|
|
558
|
+
# Emit signal
|
|
559
|
+
self._emit_signal('tags_changed', show)
|
|
560
|
+
|
|
561
|
+
return show
|
|
562
|
+
|
|
516
563
|
def delete_show(self, show):
|
|
517
564
|
"""
|
|
518
565
|
Deletes **show** completely from the list and queues the list update for the next sync.
|
|
@@ -585,7 +632,7 @@ class Engine:
|
|
|
585
632
|
def library(self):
|
|
586
633
|
return self.data_handler.library_get()
|
|
587
634
|
|
|
588
|
-
def scan_library(self, my_status=None):
|
|
635
|
+
def scan_library(self, my_status=None, ignorecache=False):
|
|
589
636
|
# Check if operation is supported by the API
|
|
590
637
|
if not self.mediainfo.get('can_play'):
|
|
591
638
|
raise utils.EngineError('Operation not supported by current site or mediatype.')
|
|
@@ -593,11 +640,11 @@ class Engine:
|
|
|
593
640
|
raise utils.EngineError('Media directory is not set.')
|
|
594
641
|
if not utils.dir_exists(self.config['searchdir']):
|
|
595
642
|
raise utils.EngineError('The set media directory doesn\'t exist.')
|
|
596
|
-
|
|
643
|
+
|
|
597
644
|
t = time.time()
|
|
598
645
|
library = {}
|
|
599
646
|
library_cache = self.data_handler.library_cache_get()
|
|
600
|
-
|
|
647
|
+
|
|
601
648
|
if not my_status:
|
|
602
649
|
my_status = self.mediainfo['status_start']
|
|
603
650
|
|
|
@@ -607,7 +654,7 @@ class Engine:
|
|
|
607
654
|
# Do a full listing of the media directory
|
|
608
655
|
for fullpath, filename in utils.regex_find_videos('mkv|mp4|avi', self.config['searchdir']):
|
|
609
656
|
show_id = None
|
|
610
|
-
if filename in library_cache.keys():
|
|
657
|
+
if not ignorecache and filename in library_cache.keys():
|
|
611
658
|
# If the filename was already seen before
|
|
612
659
|
# use the cached information, if there's no information (None)
|
|
613
660
|
# then it means it doesn't correspond to any show in the list
|
|
@@ -645,6 +692,29 @@ class Engine:
|
|
|
645
692
|
self.data_handler.library_cache_save(library_cache)
|
|
646
693
|
return library
|
|
647
694
|
|
|
695
|
+
def play_random(self):
|
|
696
|
+
"""
|
|
697
|
+
This function will pick a random show that has a new episode to watch
|
|
698
|
+
and play it.
|
|
699
|
+
"""
|
|
700
|
+
library = self.library()
|
|
701
|
+
newep = []
|
|
702
|
+
|
|
703
|
+
self.msg.info(self.name, 'Looking for random episode.')
|
|
704
|
+
|
|
705
|
+
for showid, eps in library.iteritems():
|
|
706
|
+
show = self.get_show_info(showid)
|
|
707
|
+
if show['my_progress'] + 1 in eps.keys():
|
|
708
|
+
newep.append(show)
|
|
709
|
+
|
|
710
|
+
|
|
711
|
+
if not newep:
|
|
712
|
+
raise utils.EngineError('No new episodes found to pick from.')
|
|
713
|
+
|
|
714
|
+
show = random.choice(newep)
|
|
715
|
+
ep = self.play_episode(show)
|
|
716
|
+
return (show, ep)
|
|
717
|
+
|
|
648
718
|
def play_episode(self, show, playep=0):
|
|
649
719
|
"""
|
|
650
720
|
Does a local search in the hard disk (in the folder specified by the config file)
|
|
@@ -729,6 +799,7 @@ class Engine:
|
|
|
729
799
|
"""Asks the data handler to download the remote list."""
|
|
730
800
|
self.undoall()
|
|
731
801
|
self.data_handler.download_data()
|
|
802
|
+
self._update_tracker()
|
|
732
803
|
|
|
733
804
|
def list_upload(self):
|
|
734
805
|
"""Asks the data handler to upload the unsynced changes in the queue."""
|
trackma/engine.pyc
CHANGED
|
Binary file
|
|
Binary file
|
trackma/extras/__init__.pyc
CHANGED
|
Binary file
|
trackma/extras/plex.pyc
CHANGED
|
Binary file
|
trackma/lib/__init__.pyc
CHANGED
|
Binary file
|
trackma/lib/lib.pyc
CHANGED
|
Binary file
|
trackma/lib/libanilist.py
CHANGED
|
@@ -19,7 +19,7 @@ import trackma.utils as utils
|
|
|
19
19
|
|
|
20
20
|
import json
|
|
21
21
|
import urllib, urllib2, socket
|
|
22
|
-
import time
|
|
22
|
+
import time, datetime
|
|
23
23
|
|
|
24
24
|
class libanilist(lib):
|
|
25
25
|
"""
|
|
@@ -33,7 +33,7 @@ class libanilist(lib):
|
|
|
33
33
|
msg = None
|
|
34
34
|
logged_in = False
|
|
35
35
|
|
|
36
|
-
api_info = { 'name': 'Anilist', 'version': '1', 'merge': False }
|
|
36
|
+
api_info = { 'name': 'Anilist', 'shortname': 'anilist', 'version': '1.1', 'merge': False }
|
|
37
37
|
mediatypes = dict()
|
|
38
38
|
mediatypes['anime'] = {
|
|
39
39
|
'has_progress': True,
|
|
@@ -43,6 +43,7 @@ class libanilist(lib):
|
|
|
43
43
|
'can_status': True,
|
|
44
44
|
'can_update': True,
|
|
45
45
|
'can_play': True,
|
|
46
|
+
'date_next_ep': True,
|
|
46
47
|
'status_start': 'watching',
|
|
47
48
|
'status_finish': 'completed',
|
|
48
49
|
'statuses': ['watching', 'completed', 'on-hold', 'dropped', 'plan to watch'],
|
|
@@ -220,6 +221,7 @@ class libanilist(lib):
|
|
|
220
221
|
data = self._request("GET", "user/{0}/{1}list".format(self.userid, self.mediatype), get=param)
|
|
221
222
|
|
|
222
223
|
showlist = {}
|
|
224
|
+
airinglist = []
|
|
223
225
|
|
|
224
226
|
#with open('list', 'w') as f:
|
|
225
227
|
# json.dump(data, f, indent=2)
|
|
@@ -235,7 +237,7 @@ class libanilist(lib):
|
|
|
235
237
|
|
|
236
238
|
show = utils.show()
|
|
237
239
|
showid = item[self.mediatype]['id']
|
|
238
|
-
|
|
240
|
+
showdata = {
|
|
239
241
|
'id': showid,
|
|
240
242
|
'title': item[self.mediatype]['title_romaji'],
|
|
241
243
|
'aliases': [item[self.mediatype]['title_english']],
|
|
@@ -247,28 +249,52 @@ class libanilist(lib):
|
|
|
247
249
|
'total': self._c(item[self.mediatype][self.total_str]),
|
|
248
250
|
'image': item[self.mediatype]['image_url_lge'],
|
|
249
251
|
'image_thumb': item[self.mediatype]['image_url_med'],
|
|
250
|
-
|
|
252
|
+
'url': str("http://anilist.co/%s/%d" % (self.mediatype, showid)),
|
|
253
|
+
}
|
|
254
|
+
show.update({k:v for k,v in showdata.items() if v})
|
|
255
|
+
|
|
256
|
+
if show['status'] == 1:
|
|
257
|
+
airinglist.append(showid)
|
|
251
258
|
|
|
252
259
|
showlist[showid] = show
|
|
253
260
|
|
|
261
|
+
if self.mediatype == 'anime': # Airing data unavailable for manga
|
|
262
|
+
if len(airinglist) > 0:
|
|
263
|
+
browseparam = {'access_token': self._get_userconfig('access_token'),
|
|
264
|
+
'status': 'Currently Airing',
|
|
265
|
+
'airing_data': 'true',
|
|
266
|
+
'full_page': 'true'}
|
|
267
|
+
data = self._request("GET", "browse/anime", get=browseparam)
|
|
268
|
+
for item in data:
|
|
269
|
+
id = item['id']
|
|
270
|
+
if id in showlist and 'airing' in item:
|
|
271
|
+
if item['airing']:
|
|
272
|
+
showlist[id].update({
|
|
273
|
+
'next_ep_number': item['airing']['next_episode'],
|
|
274
|
+
'next_ep_time': item['airing']['time'],
|
|
275
|
+
})
|
|
254
276
|
return showlist
|
|
255
277
|
|
|
256
278
|
def add_show(self, item):
|
|
257
279
|
self.check_credentials()
|
|
258
280
|
self.msg.info(self.name, "Adding item %s..." % item['title'])
|
|
259
|
-
|
|
281
|
+
self._update_entry(item, "POST")
|
|
260
282
|
|
|
261
283
|
def update_show(self, item):
|
|
262
284
|
self.check_credentials()
|
|
263
285
|
self.msg.info(self.name, "Updating item %s..." % item['title'])
|
|
264
|
-
|
|
286
|
+
self._update_entry(item, "PUT")
|
|
265
287
|
|
|
266
288
|
def delete_show(self, item):
|
|
267
289
|
self.check_credentials()
|
|
268
290
|
self.msg.info(self.name, "Deleting item %s..." % item['title'])
|
|
269
291
|
|
|
270
|
-
|
|
271
|
-
|
|
292
|
+
try:
|
|
293
|
+
data = self._request("DELETE", "{}list/{}".format(self.mediatype, item['id']), auth=True)
|
|
294
|
+
except ValueError:
|
|
295
|
+
# An empty document, without any JSON, is returned
|
|
296
|
+
# when the delete worked.
|
|
297
|
+
pass
|
|
272
298
|
|
|
273
299
|
def search(self, criteria):
|
|
274
300
|
self.check_credentials()
|
|
@@ -287,7 +313,7 @@ class libanilist(lib):
|
|
|
287
313
|
for item in data:
|
|
288
314
|
show = utils.show()
|
|
289
315
|
showid = item['id']
|
|
290
|
-
|
|
316
|
+
showdata = {
|
|
291
317
|
'id': showid,
|
|
292
318
|
'title': item['title_romaji'],
|
|
293
319
|
'aliases': [item['title_english']],
|
|
@@ -297,7 +323,9 @@ class libanilist(lib):
|
|
|
297
323
|
'total': item[self.total_str],
|
|
298
324
|
'image': item['image_url_lge'],
|
|
299
325
|
'image_thumb': item['image_url_med'],
|
|
300
|
-
|
|
326
|
+
'url': str("http://anilist.co/%s/%d" % (self.mediatype, showid)),
|
|
327
|
+
}
|
|
328
|
+
show.update({k:v for k,v in showdata.items() if v})
|
|
301
329
|
|
|
302
330
|
showlist.append( show )
|
|
303
331
|
|
|
@@ -333,23 +361,43 @@ class libanilist(lib):
|
|
|
333
361
|
|
|
334
362
|
def _parse_info(self, item):
|
|
335
363
|
info = utils.show()
|
|
364
|
+
showid = item['id']
|
|
336
365
|
info.update({
|
|
337
|
-
'id':
|
|
366
|
+
'id': showid,
|
|
338
367
|
'title': item['title_romaji'],
|
|
339
368
|
'status': self.status_translate[item[self.airing_str]],
|
|
340
369
|
'image': item['image_url_lge'],
|
|
370
|
+
'url': str("http://anilist.co/%s/%d" % (self.mediatype, showid)),
|
|
371
|
+
'start_date': self._str2date(item.get('start_date')),
|
|
372
|
+
'end_date': self._str2date(item.get('end_date')),
|
|
341
373
|
'extra': [
|
|
342
|
-
('
|
|
343
|
-
('
|
|
374
|
+
('English', item.get('title_english')),
|
|
375
|
+
('Japanese', item.get('title_japanese')),
|
|
344
376
|
('Classification', item.get('classification')),
|
|
345
|
-
('
|
|
377
|
+
('Genres', item.get('genres')),
|
|
378
|
+
('Synopsis', item.get('description')),
|
|
379
|
+
('Type', item.get('type')),
|
|
346
380
|
('Average score', item.get('average_score')),
|
|
347
|
-
('
|
|
348
|
-
('
|
|
381
|
+
('Status', item.get(self.airing_str)),
|
|
382
|
+
('Start Date', item.get('start_date')),
|
|
383
|
+
('End Date', item.get('end_date')),
|
|
349
384
|
]
|
|
350
385
|
})
|
|
351
386
|
return info
|
|
352
387
|
|
|
388
|
+
def _str2date(self, string):
|
|
389
|
+
if string is not None:
|
|
390
|
+
try:
|
|
391
|
+
return datetime.datetime.strptime(string[:10], "%Y-%m-%d")
|
|
392
|
+
except ValueError:
|
|
393
|
+
return None # Ignore date if it's invalid
|
|
394
|
+
else:
|
|
395
|
+
return None
|
|
396
|
+
|
|
397
|
+
|
|
353
398
|
def _c(self, s):
|
|
354
|
-
|
|
399
|
+
if s is None:
|
|
400
|
+
return 0
|
|
401
|
+
else:
|
|
402
|
+
return s
|
|
355
403
|
|
trackma/lib/libanilist.pyc
CHANGED
|
Binary file
|
trackma/lib/libhb.py
CHANGED
|
@@ -38,7 +38,7 @@ class libhb(lib):
|
|
|
38
38
|
auth = ''
|
|
39
39
|
logged_in = False
|
|
40
40
|
|
|
41
|
-
api_info = { 'name': 'Hummingbird', 'version': 'v0.2', 'merge': False }
|
|
41
|
+
api_info = { 'name': 'Hummingbird', 'shortname': 'hb', 'version': 'v0.2', 'merge': False }
|
|
42
42
|
|
|
43
43
|
default_mediatype = 'anime'
|
|
44
44
|
mediatypes = dict()
|
|
@@ -136,6 +136,7 @@ class libhb(lib):
|
|
|
136
136
|
'my_status': show['status'],
|
|
137
137
|
'total': int(epCount) if epCount is not None else 0,
|
|
138
138
|
'image': show['anime']['cover_image'],
|
|
139
|
+
'url': str("http://hummingbird.me/%s/%d" % (self.mediatype, showid)),
|
|
139
140
|
})
|
|
140
141
|
info = self._parse_info(show['anime'])
|
|
141
142
|
infolist.append(info)
|
|
@@ -166,8 +167,7 @@ class libhb(lib):
|
|
|
166
167
|
values['sane_rating_update'] = item['my_score']
|
|
167
168
|
|
|
168
169
|
try:
|
|
169
|
-
|
|
170
|
-
return True
|
|
170
|
+
self._request("/libraries/%s" % item['id'], post=values)
|
|
171
171
|
except urllib2.HTTPError, e:
|
|
172
172
|
raise utils.APIError('Error updating: ' + str(e.code))
|
|
173
173
|
|
|
@@ -178,8 +178,7 @@ class libhb(lib):
|
|
|
178
178
|
|
|
179
179
|
values = {'auth_token': self.auth}
|
|
180
180
|
try:
|
|
181
|
-
|
|
182
|
-
return True
|
|
181
|
+
self._request("/libraries/%s/remove" % item['id'], post=values)
|
|
183
182
|
except urllib2.HTTPError, e:
|
|
184
183
|
raise utils.APIError('Error deleting: ' + str(e.code))
|
|
185
184
|
|
trackma/lib/libhb.pyc
CHANGED
|
Binary file
|