trackma 0.6.2__py3.4.egg → 0.7.1__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.
Files changed (65) hide show
  1. EGG-INFO/PKG-INFO +1 -1
  2. EGG-INFO/SOURCES.txt +10 -6
  3. EGG-INFO/requires.txt +0 -2
  4. trackma/__pycache__/__init__.cpython-34.pyc +0 -0
  5. trackma/__pycache__/accounts.cpython-34.pyc +0 -0
  6. trackma/__pycache__/data.cpython-34.pyc +0 -0
  7. trackma/__pycache__/engine.cpython-34.pyc +0 -0
  8. trackma/__pycache__/messenger.cpython-34.pyc +0 -0
  9. trackma/__pycache__/utils.cpython-34.pyc +0 -0
  10. trackma/data/kitsu.png +0 -0
  11. trackma/data.py +26 -16
  12. trackma/engine.py +68 -17
  13. trackma/extras/AnimeInfoExtractor.py +1 -1
  14. trackma/extras/__pycache__/AnimeInfoExtractor.cpython-34.pyc +0 -0
  15. trackma/extras/__pycache__/__init__.cpython-34.pyc +0 -0
  16. trackma/lib/__pycache__/__init__.cpython-34.pyc +0 -0
  17. trackma/lib/__pycache__/lib.cpython-34.pyc +0 -0
  18. trackma/lib/__pycache__/libanilist.cpython-34.pyc +0 -0
  19. trackma/lib/__pycache__/libkitsu.cpython-34.pyc +0 -0
  20. trackma/lib/__pycache__/libmal.cpython-34.pyc +0 -0
  21. trackma/lib/__pycache__/libshikimori.cpython-34.pyc +0 -0
  22. trackma/lib/__pycache__/libvndb.cpython-34.pyc +0 -0
  23. trackma/lib/libanilist.py +3 -3
  24. trackma/lib/libkitsu.py +507 -0
  25. trackma/lib/libmal.py +6 -6
  26. trackma/lib/libshikimori.py +3 -3
  27. trackma/lib/libvndb.py +12 -9
  28. trackma/messenger.py +1 -1
  29. trackma/tracker/__init__.py +0 -0
  30. trackma/tracker/__pycache__/__init__.cpython-34.pyc +0 -0
  31. trackma/tracker/__pycache__/inotify.cpython-34.pyc +0 -0
  32. trackma/tracker/__pycache__/inotifyBase.cpython-34.pyc +0 -0
  33. trackma/tracker/__pycache__/plex.cpython-34.pyc +0 -0
  34. trackma/tracker/__pycache__/polling.cpython-34.pyc +0 -0
  35. trackma/tracker/__pycache__/pyinotify.cpython-34.pyc +0 -0
  36. trackma/tracker/__pycache__/tracker.cpython-34.pyc +0 -0
  37. trackma/tracker/__pycache__/win32.cpython-34.pyc +0 -0
  38. trackma/tracker/inotify.py +69 -0
  39. trackma/tracker/inotifyBase.py +110 -0
  40. trackma/tracker/plex.py +106 -0
  41. trackma/tracker/polling.py +55 -0
  42. trackma/tracker/pyinotify.py +90 -0
  43. trackma/tracker/tracker.py +221 -0
  44. trackma/tracker/win32.py +74 -0
  45. trackma/ui/__pycache__/__init__.cpython-34.pyc +0 -0
  46. trackma/ui/__pycache__/cli.cpython-34.pyc +0 -0
  47. trackma/ui/__pycache__/curses.cpython-34.pyc +0 -0
  48. trackma/ui/__pycache__/gtkui.cpython-34.pyc +0 -0
  49. trackma/ui/__pycache__/qt4ui.cpython-34.pyc +0 -0
  50. trackma/ui/__pycache__/qtui.cpython-34.pyc +0 -0
  51. trackma/ui/cli.py +110 -13
  52. trackma/ui/curses.py +88 -30
  53. trackma/ui/gtkui.py +120 -58
  54. trackma/ui/qtui.py +161 -49
  55. trackma/utils.py +16 -9
  56. trackma/__pycache__/tracker.cpython-34.pyc +0 -0
  57. trackma/data/hb.jpg +0 -0
  58. trackma/data/melative.jpg +0 -0
  59. trackma/extras/__pycache__/plex.cpython-34.pyc +0 -0
  60. trackma/extras/plex.py +0 -101
  61. trackma/lib/__pycache__/libhb.cpython-34.pyc +0 -0
  62. trackma/lib/__pycache__/libmelative.cpython-34.pyc +0 -0
  63. trackma/lib/libhb.py +0 -239
  64. trackma/lib/libmelative.py +0 -204
  65. trackma/tracker.py +0 -430
EGG-INFO/PKG-INFO CHANGED
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.1
2
2
  Name: Trackma
3
- Version: 0.6.2
3
+ Version: 0.7.1
4
4
  Summary: Open multi-site list manager
5
5
  Home-page: https://github.com/z411/trackma
6
6
  Author: z411
EGG-INFO/SOURCES.txt CHANGED
@@ -20,28 +20,32 @@ trackma/accounts.py
20
20
  trackma/data.py
21
21
  trackma/engine.py
22
22
  trackma/messenger.py
23
- trackma/tracker.py
24
23
  trackma/trackma.kdev4
25
24
  trackma/utils.py
26
25
  trackma/.kdev4/trackma.kdev4
27
26
  trackma/data/anilist.jpg
28
- trackma/data/hb.jpg
29
27
  trackma/data/icon.png
28
+ trackma/data/kitsu.png
30
29
  trackma/data/mal.jpg
31
- trackma/data/melative.jpg
32
30
  trackma/data/shikimori.jpg
33
31
  trackma/data/vndb.jpg
34
32
  trackma/extras/AnimeInfoExtractor.py
35
33
  trackma/extras/__init__.py
36
- trackma/extras/plex.py
37
34
  trackma/lib/__init__.py
38
35
  trackma/lib/lib.py
39
36
  trackma/lib/libanilist.py
40
- trackma/lib/libhb.py
37
+ trackma/lib/libkitsu.py
41
38
  trackma/lib/libmal.py
42
- trackma/lib/libmelative.py
43
39
  trackma/lib/libshikimori.py
44
40
  trackma/lib/libvndb.py
41
+ trackma/tracker/__init__.py
42
+ trackma/tracker/inotify.py
43
+ trackma/tracker/inotifyBase.py
44
+ trackma/tracker/plex.py
45
+ trackma/tracker/polling.py
46
+ trackma/tracker/pyinotify.py
47
+ trackma/tracker/tracker.py
48
+ trackma/tracker/win32.py
45
49
  trackma/ui/__init__.py
46
50
  trackma/ui/cli.py
47
51
  trackma/ui/curses.py
EGG-INFO/requires.txt CHANGED
@@ -1,10 +1,8 @@
1
1
 
2
2
  [GTK]
3
3
  pygobject
4
- Pillow
5
4
 
6
5
  [Qt]
7
- Pillow
8
6
 
9
7
  [curses]
10
8
  urwid
Binary file
Binary file
Binary file
Binary file
Binary file
trackma/data/kitsu.png ADDED
Binary file
trackma/data.py CHANGED
@@ -103,6 +103,14 @@ class Data():
103
103
  if self.signals[signal]:
104
104
  self.signals[signal](*args)
105
105
 
106
+ def _is_queue_ready(self):
107
+ # Checks if queue should be sent ASAP
108
+ # Note: Hours setting is DEPRECATED!
109
+ return (self.config['autosend'] == 'always' or
110
+ (self.config['autosend'] == 'hours' and time.time() - self.meta['lastsend'] >= self.config['autosend_hours']*3600) or
111
+ (self.config['autosend'] == 'minutes' and time.time() - self.meta['lastsend'] >= self.config['autosend_minutes']*60) or
112
+ (self.config['autosend'] == 'size' and len(self.queue) >= self.config['autosend_size']))
113
+
106
114
  def connect_signal(self, signal, callback):
107
115
  try:
108
116
  self.signals[signal] = callback
@@ -131,6 +139,7 @@ class Data():
131
139
 
132
140
  if self._queue_exists() and self.meta.get('version') == self.version:
133
141
  self._load_queue()
142
+ self._emit_signal('queue_changed', self.queue)
134
143
 
135
144
  if self._info_exists() and self.meta.get('version') == self.version:
136
145
  # Load info cache only if we're on the same database version
@@ -140,12 +149,13 @@ class Data():
140
149
  # otherwise query the API for a remote list
141
150
  if self._cache_exists() and self.meta.get('version') == self.version:
142
151
  # Auto-send: Process the queue if we're beyond the auto-send time limit for some reason
143
- if self.config['autosend'] == 'hours' and time.time() - self.meta['lastsend'] > self.config['autosend_hours'] * 3600:
152
+ if self._is_queue_ready():
144
153
  self.process_queue()
145
154
 
146
155
  # Auto-retrieve: Redownload list if any autoretrieve condition is met
147
156
  if (self.config['autoretrieve'] == 'always' or
148
- (self.config['autoretrieve'] == 'days' and time.time() - self.meta['lastget'] > self.config['autoretrieve_days'] * 84600) or
157
+ (self.config['autoretrieve'] == 'days' and
158
+ time.time() - self.meta['lastget'] > self.config['autoretrieve_days'] * 84600) or
149
159
  self.meta.get('version') != self.version):
150
160
  try:
151
161
  # Make sure we process the queue first before overwriting the list
@@ -165,7 +175,8 @@ class Data():
165
175
  raise utils.APIFatal(str(e))
166
176
 
167
177
  # Create autosend thread if needed
168
- if self.config['autosend'] == 'hours':
178
+ # Note: Hours setting is DEPRECATED!
179
+ if self.config['autosend'] in ('minutes', 'hours'):
169
180
  self.autosend()
170
181
 
171
182
  return (self.api.api_info, self.api.media_info())
@@ -241,7 +252,7 @@ class Data():
241
252
 
242
253
  self._save_queue()
243
254
  self._save_cache()
244
- self._emit_signal('queue_changed', len(self.queue))
255
+ self._emit_signal('queue_changed', self.queue)
245
256
  self.msg.info(self.name, "Queued add for %s" % show['title'])
246
257
 
247
258
  def queue_update(self, show, key, value):
@@ -255,7 +266,7 @@ class Data():
255
266
  key: The key that will be modified (it must exist beforehand)
256
267
  value: The value that it should be changed to
257
268
  """
258
- if key not in show.keys():
269
+ if key not in show:
259
270
  raise utils.DataError('Invalid key for queue update.')
260
271
 
261
272
  # Do update on memory
@@ -284,13 +295,11 @@ class Data():
284
295
 
285
296
  self._save_queue()
286
297
  self._save_cache()
287
- self._emit_signal('queue_changed', len(self.queue))
298
+ self._emit_signal('queue_changed', self.queue)
288
299
  self.msg.info(self.name, "Queued update for %s" % show['title'])
289
300
 
290
301
  # Immediately process the action if necessary
291
- if (self.config['autosend'] == 'always' or
292
- (self.config['autosend'] == 'hours' and time.time() - self.meta['lastsend'] >= self.config['autosend_hours']*3600) or
293
- (self.config['autosend'] == 'size' and len(self.queue) >= self.config['autosend_size'])):
302
+ if self._is_queue_ready():
294
303
  self.process_queue()
295
304
 
296
305
  def queue_delete(self, show):
@@ -327,7 +336,7 @@ class Data():
327
336
 
328
337
  self._save_queue()
329
338
  self._save_cache()
330
- self._emit_signal('queue_changed', len(self.queue))
339
+ self._emit_signal('queue_changed', self.queue)
331
340
  self.msg.info(self.name, "Queued delete for %s" % item['title'])
332
341
 
333
342
  def queue_clear(self):
@@ -335,7 +344,7 @@ class Data():
335
344
  if self.queue:
336
345
  self.queue = []
337
346
  self._save_queue()
338
- self._emit_signal('queue_changed', len(self.queue))
347
+ self._emit_signal('queue_changed', self.queue)
339
348
  self.msg.info(self.name, "Cleared queue.")
340
349
 
341
350
  def process_queue(self):
@@ -391,7 +400,7 @@ class Data():
391
400
  self._emit_signal('show_synced', show, item)
392
401
 
393
402
  items_processed.append((show, item))
394
- self._emit_signal('queue_changed', len(self.queue))
403
+ self._emit_signal('queue_changed', self.queue)
395
404
  except utils.APIError as e:
396
405
  self.msg.warn(self.name, "Can't process %s, will leave unsynced." % item['title'])
397
406
  self.msg.debug(self.name, "Info: %s" % e)
@@ -467,12 +476,13 @@ class Data():
467
476
 
468
477
  def autosend(self):
469
478
  # Check if we should autosend now
470
- if time.time() - self.meta['lastsend'] >= self.config['autosend_hours'] * 3600:
479
+ if self._is_queue_ready():
471
480
  self.process_queue()
472
481
 
473
- # Repeat check only if the settings are still on 'hours'
474
- if self.config['autosend'] == 'hours':
475
- self.autosend_timer = threading.Timer(3600, self.autosend)
482
+ # Repeat check only if the settings are still on autosend
483
+ # Note: Hours setting is DEPRECATED!
484
+ if self.config['autosend'] in ('minutes', 'hours'):
485
+ self.autosend_timer = threading.Timer(3600 if self.config['autosend'] == 'hours' else 60, self.autosend)
476
486
  self.autosend_timer.daemon = True
477
487
  self.autosend_timer.start()
478
488
 
trackma/engine.py CHANGED
@@ -1,4 +1,4 @@
1
- # This file is part of wMAL.
1
+ # This file is part of Trackma.
2
2
  #
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU General Public License as published by
@@ -27,7 +27,6 @@ from decimal import Decimal
27
27
 
28
28
  from trackma import messenger
29
29
  from trackma import data
30
- from trackma import tracker
31
30
  from trackma import utils
32
31
  from trackma.extras import AnimeInfoExtractor
33
32
 
@@ -67,7 +66,10 @@ class Engine:
67
66
  'sync_complete': None,
68
67
  'queue_changed': None,
69
68
  'playing': None,
70
- 'prompt_for_update': None, }
69
+ 'prompt_for_update': None,
70
+ 'prompt_for_add': None,
71
+ 'tracker_state': None,
72
+ }
71
73
 
72
74
  def __init__(self, account, message_handler=None):
73
75
  """Reads configuration file and asks the data handler for the API info."""
@@ -150,7 +152,17 @@ class Engine:
150
152
  if self.config['tracker_update_prompt']:
151
153
  self._emit_signal('prompt_for_update', show, episode)
152
154
  else:
153
- self.set_episode(show['id'], episode)
155
+ try:
156
+ self.set_episode(show['id'], episode)
157
+ except utils.TrackmaError as e:
158
+ self.msg.warn(self.name, "Can't update episode: {}".format(e))
159
+
160
+ def _tracker_unrecognised(self, show_title, episode):
161
+ if self.config['tracker_not_found_prompt']:
162
+ self._emit_signal('prompt_for_add', show_title, episode)
163
+
164
+ def _tracker_state(self, state, timer):
165
+ self._emit_signal('tracker_state', state, timer)
154
166
 
155
167
  def _emit_signal(self, signal, *args):
156
168
  try:
@@ -181,9 +193,10 @@ class Engine:
181
193
  tracker_list.append({'id': show['id'],
182
194
  'title': show['title'],
183
195
  'my_progress': show['my_progress'],
196
+ 'total': show['total'],
184
197
  'type': None,
185
- 'titles': self.data_handler.get_show_titles(show),
186
- }) # TODO types
198
+ 'titles': self.data_handler.get_show_titles(show),
199
+ }) # TODO types
187
200
 
188
201
  return tracker_list
189
202
 
@@ -235,18 +248,41 @@ class Engine:
235
248
 
236
249
  # Start tracker
237
250
  if self.mediainfo.get('can_play') and self.config['tracker_enabled']:
238
- self.tracker = tracker.Tracker(self.msg,
251
+ # Choose the tracker we want to tart
252
+ if self.config['tracker_type'] == 'plex':
253
+ from trackma.tracker.plex import PlexTracker
254
+ TrackerClass = PlexTracker
255
+ elif os.name == 'nt':
256
+ from trackma.tracker.win32 import Win32Tracker
257
+ TrackerClass = Win32Tracker
258
+ else:
259
+ # Try trackers in this order: pyinotify, inotify, polling
260
+ try:
261
+ from trackma.tracker.pyinotify import pyinotifyTracker
262
+ TrackerClass = pyinotifyTracker
263
+ except ImportError:
264
+ try:
265
+ from trackma.tracker.inotify import inotifyTracker
266
+ TrackerClass = inotifyTracker
267
+ except ImportError:
268
+ from trackma.tracker.polling import PollingTracker
269
+ TrackerClass = PollingTracker
270
+
271
+ self.tracker = TrackerClass(self.msg,
239
272
  self._get_tracker_list(),
240
273
  self.config['tracker_process'],
241
274
  self.config['searchdir'],
242
275
  int(self.config['tracker_interval']),
243
276
  int(self.config['tracker_update_wait_s']),
244
277
  self.config['tracker_update_close'],
278
+ self.config['tracker_not_found_prompt'],
245
279
  )
246
280
  self.tracker.connect_signal('detected', self._tracker_detected)
247
281
  self.tracker.connect_signal('removed', self._tracker_removed)
248
282
  self.tracker.connect_signal('playing', self._tracker_playing)
249
283
  self.tracker.connect_signal('update', self._tracker_update)
284
+ self.tracker.connect_signal('unrecognised', self._tracker_unrecognised)
285
+ self.tracker.connect_signal('state', self._tracker_state)
250
286
 
251
287
  self.loaded = True
252
288
  return True
@@ -350,6 +386,16 @@ class Engine:
350
386
 
351
387
  return newlist
352
388
 
389
+ def tracker_status(self):
390
+ """
391
+ Asks the tracker for its current status.
392
+ """
393
+
394
+ if self.tracker:
395
+ return self.tracker.get_status()
396
+ else:
397
+ return None
398
+
353
399
  def search(self, criteria):
354
400
  """
355
401
  Request a remote list of shows matching the criteria
@@ -546,7 +592,7 @@ class Engine:
546
592
 
547
593
  # Check if the status is valid
548
594
  _statuses = self.mediainfo['statuses_dict']
549
- if newstatus not in _statuses.keys():
595
+ if newstatus not in _statuses:
550
596
  raise utils.EngineError('Invalid status.')
551
597
 
552
598
  # Get the show and update it
@@ -650,6 +696,9 @@ class Engine:
650
696
  return best_candidate[0], best_candidate[2]
651
697
 
652
698
  def get_new_episodes(self, showlist):
699
+ # DEPRECATED !
700
+ self.msg.debug(self.name, "DEPRECATED: get_new_episodes")
701
+
653
702
  results = list()
654
703
  total = len(showlist)
655
704
  t = time.time()
@@ -705,9 +754,9 @@ class Engine:
705
754
  tracker_list = self._get_tracker_list()
706
755
  fullpath = path+"/"+filename
707
756
  # Only remove if the filename matches library entry
708
- if filename in library_cache.keys() and library_cache[filename]:
757
+ if filename in library_cache and library_cache[filename]:
709
758
  (show_id, show_ep) = library_cache[filename]
710
- if show_id and show_id in library.keys() \
759
+ if show_id and show_id in library \
711
760
  and show_ep and show_ep in library[show_id].keys():
712
761
  if library[show_id][show_ep] == fullpath:
713
762
  self.msg.debug(self.name, "File removed from local library: %s" % fullpath)
@@ -725,7 +774,7 @@ class Engine:
725
774
 
726
775
  def _add_show_to_library(self, library, library_cache, rescan, fullpath, filename, tracker_list):
727
776
  show_id = None
728
- if not rescan and filename in library_cache.keys():
777
+ if not rescan and filename in library_cache:
729
778
  # If the filename was already seen before
730
779
  # use the cached information, if there's no information (None)
731
780
  # then it means it doesn't correspond to any show in the list
@@ -736,9 +785,9 @@ class Engine:
736
785
  (show_ep_start, show_ep_end) = show_ep
737
786
  else:
738
787
  show_ep_start = show_ep_end = show_ep
739
- self.msg.debug(self.name, "File already in library: {}".format(fullpath))
788
+ self.msg.debug(self.name, "File in cache: {}".format(fullpath))
740
789
  else:
741
- self.msg.debug(self.name, "???: {}".format(fullpath))
790
+ self.msg.debug(self.name, "File in cache but skipped: {}".format(fullpath))
742
791
  return library, library_cache
743
792
  else:
744
793
  # If the filename has not been seen, extract
@@ -751,21 +800,23 @@ class Engine:
751
800
  if show_title:
752
801
  show = utils.guess_show(show_title, tracker_list)
753
802
  if show:
803
+ self.msg.debug(self.name, "Adding to library: {}".format(fullpath))
804
+
754
805
  show_id = show['id']
755
806
  if show_ep_start == show_ep_end:
756
807
  library_cache[filename] = (show['id'], show_ep_start)
757
808
  else:
758
809
  library_cache[filename] = (show['id'], (show_ep_start, show_ep_end))
759
-
760
- self.msg.debug(self.name, "New file added to local library: {}".format(fullpath))
761
810
  else:
811
+ self.msg.debug(self.name, "Not a show, skipping: {}".format(fullpath))
762
812
  library_cache[filename] = None
763
813
  else:
814
+ self.msg.debug(self.name, "Not recognized, skipping: {}".format(fullpath))
764
815
  library_cache[filename] = None
765
816
 
766
817
  # After we got our information, add it to our library
767
818
  if show_id:
768
- if show_id not in library.keys():
819
+ if show_id not in library:
769
820
  library[show_id] = {}
770
821
  for show_ep in range(show_ep_start, show_ep_end+1):
771
822
  library[show_id][show_ep] = fullpath
@@ -798,7 +849,7 @@ class Engine:
798
849
 
799
850
  for showid, eps in library.items():
800
851
  show = self.get_show_info(showid)
801
- if show['my_progress'] + 1 in eps.keys():
852
+ if show['my_progress'] + 1 in eps:
802
853
  newep.append(show)
803
854
 
804
855
  if not newep:
@@ -1,4 +1,4 @@
1
- # This file is part of wMAL.
1
+ # This file is part of Trackma.
2
2
  #
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU General Public License as published by
Binary file
trackma/lib/libanilist.py CHANGED
@@ -356,11 +356,11 @@ class libanilist(lib):
356
356
 
357
357
  def _update_entry(self, item, method):
358
358
  values = { 'id': item['id'] }
359
- if 'my_progress' in item.keys():
359
+ if 'my_progress' in item:
360
360
  values[self.watched_str] = item['my_progress']
361
- if 'my_status' in item.keys():
361
+ if 'my_status' in item:
362
362
  values['list_status'] = item['my_status']
363
- if 'my_score' in item.keys():
363
+ if 'my_score' in item:
364
364
  values['score'] = item['my_score']
365
365
 
366
366
  data = self._request(method, "{}list".format(self.mediatype), post=values, auth=True)