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.
Files changed (62) hide show
  1. EGG-INFO/PKG-INFO +1 -1
  2. EGG-INFO/SOURCES.txt +9 -6
  3. trackma/__pycache__/__init__.cpython-34.pyc +0 -0
  4. trackma/__pycache__/accounts.cpython-34.pyc +0 -0
  5. trackma/__pycache__/data.cpython-34.pyc +0 -0
  6. trackma/__pycache__/engine.cpython-34.pyc +0 -0
  7. trackma/__pycache__/messenger.cpython-34.pyc +0 -0
  8. trackma/__pycache__/utils.cpython-34.pyc +0 -0
  9. trackma/data/kitsu.png +0 -0
  10. trackma/data.py +26 -16
  11. trackma/engine.py +60 -16
  12. trackma/extras/AnimeInfoExtractor.py +1 -1
  13. trackma/extras/__pycache__/AnimeInfoExtractor.cpython-34.pyc +0 -0
  14. trackma/extras/__pycache__/__init__.cpython-34.pyc +0 -0
  15. trackma/lib/__pycache__/__init__.cpython-34.pyc +0 -0
  16. trackma/lib/__pycache__/lib.cpython-34.pyc +0 -0
  17. trackma/lib/__pycache__/libanilist.cpython-34.pyc +0 -0
  18. trackma/lib/__pycache__/libkitsu.cpython-34.pyc +0 -0
  19. trackma/lib/__pycache__/libmal.cpython-34.pyc +0 -0
  20. trackma/lib/__pycache__/libshikimori.cpython-34.pyc +0 -0
  21. trackma/lib/__pycache__/libvndb.cpython-34.pyc +0 -0
  22. trackma/lib/libanilist.py +3 -3
  23. trackma/lib/libkitsu.py +478 -0
  24. trackma/lib/libmal.py +6 -6
  25. trackma/lib/libshikimori.py +3 -3
  26. trackma/lib/libvndb.py +12 -9
  27. trackma/messenger.py +1 -1
  28. trackma/tracker/__init__.py +0 -0
  29. trackma/tracker/__pycache__/__init__.cpython-34.pyc +0 -0
  30. trackma/tracker/__pycache__/inotify.cpython-34.pyc +0 -0
  31. trackma/tracker/__pycache__/plex.cpython-34.pyc +0 -0
  32. trackma/tracker/__pycache__/polling.cpython-34.pyc +0 -0
  33. trackma/tracker/__pycache__/pyinotify.cpython-34.pyc +0 -0
  34. trackma/tracker/__pycache__/tracker.cpython-34.pyc +0 -0
  35. trackma/tracker/__pycache__/win32.cpython-34.pyc +0 -0
  36. trackma/tracker/inotify.py +123 -0
  37. trackma/tracker/plex.py +99 -0
  38. trackma/tracker/polling.py +55 -0
  39. trackma/tracker/pyinotify.py +143 -0
  40. trackma/tracker/tracker.py +213 -0
  41. trackma/tracker/win32.py +74 -0
  42. trackma/ui/__pycache__/__init__.cpython-34.pyc +0 -0
  43. trackma/ui/__pycache__/cli.cpython-34.pyc +0 -0
  44. trackma/ui/__pycache__/curses.cpython-34.pyc +0 -0
  45. trackma/ui/__pycache__/gtkui.cpython-34.pyc +0 -0
  46. trackma/ui/__pycache__/qt4ui.cpython-34.pyc +0 -0
  47. trackma/ui/__pycache__/qtui.cpython-34.pyc +0 -0
  48. trackma/ui/cli.py +109 -12
  49. trackma/ui/curses.py +87 -29
  50. trackma/ui/gtkui.py +81 -45
  51. trackma/ui/qtui.py +95 -34
  52. trackma/utils.py +15 -9
  53. trackma/__pycache__/tracker.cpython-34.pyc +0 -0
  54. trackma/data/hb.jpg +0 -0
  55. trackma/data/melative.jpg +0 -0
  56. trackma/extras/__pycache__/plex.cpython-34.pyc +0 -0
  57. trackma/extras/plex.py +0 -101
  58. trackma/lib/__pycache__/libhb.cpython-34.pyc +0 -0
  59. trackma/lib/__pycache__/libmelative.cpython-34.pyc +0 -0
  60. trackma/lib/libhb.py +0 -239
  61. trackma/lib/libmelative.py +0 -204
  62. 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
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,31 @@ 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/plex.py
44
+ trackma/tracker/polling.py
45
+ trackma/tracker/pyinotify.py
46
+ trackma/tracker/tracker.py
47
+ trackma/tracker/win32.py
45
48
  trackma/ui/__init__.py
46
49
  trackma/ui/cli.py
47
50
  trackma/ui/curses.py
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."""
@@ -152,6 +154,13 @@ class Engine:
152
154
  else:
153
155
  self.set_episode(show['id'], episode)
154
156
 
157
+ def _tracker_unrecognised(self, show_title, episode):
158
+ if self.config['tracker_not_found_prompt']:
159
+ self._emit_signal('prompt_for_add', show_title, episode)
160
+
161
+ def _tracker_state(self, state, timer):
162
+ self._emit_signal('tracker_state', state, timer)
163
+
155
164
  def _emit_signal(self, signal, *args):
156
165
  try:
157
166
  # Call the signal function
@@ -182,8 +191,8 @@ class Engine:
182
191
  'title': show['title'],
183
192
  'my_progress': show['my_progress'],
184
193
  'type': None,
185
- 'titles': self.data_handler.get_show_titles(show),
186
- }) # TODO types
194
+ 'titles': self.data_handler.get_show_titles(show),
195
+ }) # TODO types
187
196
 
188
197
  return tracker_list
189
198
 
@@ -235,18 +244,41 @@ class Engine:
235
244
 
236
245
  # Start tracker
237
246
  if self.mediainfo.get('can_play') and self.config['tracker_enabled']:
238
- self.tracker = tracker.Tracker(self.msg,
247
+ # Choose the tracker we want to tart
248
+ if self.config['tracker_type'] == 'plex':
249
+ from trackma.tracker.plex import PlexTracker
250
+ TrackerClass = PlexTracker
251
+ elif os.name == 'nt':
252
+ from trackma.tracker.win32 import Win32Tracker
253
+ TrackerClass = Win32Tracker
254
+ else:
255
+ # Try trackers in this order: pyinotify, inotify, polling
256
+ try:
257
+ from trackma.tracker.pyinotify import pyinotifyTracker
258
+ TrackerClass = pyinotifyTracker
259
+ except ImportError:
260
+ try:
261
+ from trackma.tracker.inotify import inotifyTracker
262
+ TrackerClass = inotifyTracker
263
+ except ImportError:
264
+ from trackma.tracker.polling import PollingTracker
265
+ TrackerClass = PollingTracker
266
+
267
+ self.tracker = TrackerClass(self.msg,
239
268
  self._get_tracker_list(),
240
269
  self.config['tracker_process'],
241
270
  self.config['searchdir'],
242
271
  int(self.config['tracker_interval']),
243
272
  int(self.config['tracker_update_wait_s']),
244
273
  self.config['tracker_update_close'],
274
+ self.config['tracker_not_found_prompt'],
245
275
  )
246
276
  self.tracker.connect_signal('detected', self._tracker_detected)
247
277
  self.tracker.connect_signal('removed', self._tracker_removed)
248
278
  self.tracker.connect_signal('playing', self._tracker_playing)
249
279
  self.tracker.connect_signal('update', self._tracker_update)
280
+ self.tracker.connect_signal('unrecognised', self._tracker_unrecognised)
281
+ self.tracker.connect_signal('state', self._tracker_state)
250
282
 
251
283
  self.loaded = True
252
284
  return True
@@ -350,6 +382,16 @@ class Engine:
350
382
 
351
383
  return newlist
352
384
 
385
+ def tracker_status(self):
386
+ """
387
+ Asks the tracker for its current status.
388
+ """
389
+
390
+ if self.tracker:
391
+ return self.tracker.get_status()
392
+ else:
393
+ return None
394
+
353
395
  def search(self, criteria):
354
396
  """
355
397
  Request a remote list of shows matching the criteria
@@ -546,7 +588,7 @@ class Engine:
546
588
 
547
589
  # Check if the status is valid
548
590
  _statuses = self.mediainfo['statuses_dict']
549
- if newstatus not in _statuses.keys():
591
+ if newstatus not in _statuses:
550
592
  raise utils.EngineError('Invalid status.')
551
593
 
552
594
  # Get the show and update it
@@ -705,9 +747,9 @@ class Engine:
705
747
  tracker_list = self._get_tracker_list()
706
748
  fullpath = path+"/"+filename
707
749
  # Only remove if the filename matches library entry
708
- if filename in library_cache.keys() and library_cache[filename]:
750
+ if filename in library_cache and library_cache[filename]:
709
751
  (show_id, show_ep) = library_cache[filename]
710
- if show_id and show_id in library.keys() \
752
+ if show_id and show_id in library \
711
753
  and show_ep and show_ep in library[show_id].keys():
712
754
  if library[show_id][show_ep] == fullpath:
713
755
  self.msg.debug(self.name, "File removed from local library: %s" % fullpath)
@@ -725,7 +767,7 @@ class Engine:
725
767
 
726
768
  def _add_show_to_library(self, library, library_cache, rescan, fullpath, filename, tracker_list):
727
769
  show_id = None
728
- if not rescan and filename in library_cache.keys():
770
+ if not rescan and filename in library_cache:
729
771
  # If the filename was already seen before
730
772
  # use the cached information, if there's no information (None)
731
773
  # then it means it doesn't correspond to any show in the list
@@ -736,9 +778,9 @@ class Engine:
736
778
  (show_ep_start, show_ep_end) = show_ep
737
779
  else:
738
780
  show_ep_start = show_ep_end = show_ep
739
- self.msg.debug(self.name, "File already in library: {}".format(fullpath))
781
+ self.msg.debug(self.name, "File in cache: {}".format(fullpath))
740
782
  else:
741
- self.msg.debug(self.name, "???: {}".format(fullpath))
783
+ self.msg.debug(self.name, "File in cache but skipped: {}".format(fullpath))
742
784
  return library, library_cache
743
785
  else:
744
786
  # If the filename has not been seen, extract
@@ -751,21 +793,23 @@ class Engine:
751
793
  if show_title:
752
794
  show = utils.guess_show(show_title, tracker_list)
753
795
  if show:
796
+ self.msg.debug(self.name, "Adding to library: {}".format(fullpath))
797
+
754
798
  show_id = show['id']
755
799
  if show_ep_start == show_ep_end:
756
800
  library_cache[filename] = (show['id'], show_ep_start)
757
801
  else:
758
802
  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
803
  else:
804
+ self.msg.debug(self.name, "Not a show, skipping: {}".format(fullpath))
762
805
  library_cache[filename] = None
763
806
  else:
807
+ self.msg.debug(self.name, "Not recognized, skipping: {}".format(fullpath))
764
808
  library_cache[filename] = None
765
809
 
766
810
  # After we got our information, add it to our library
767
811
  if show_id:
768
- if show_id not in library.keys():
812
+ if show_id not in library:
769
813
  library[show_id] = {}
770
814
  for show_ep in range(show_ep_start, show_ep_end+1):
771
815
  library[show_id][show_ep] = fullpath
@@ -798,7 +842,7 @@ class Engine:
798
842
 
799
843
  for showid, eps in library.items():
800
844
  show = self.get_show_info(showid)
801
- if show['my_progress'] + 1 in eps.keys():
845
+ if show['my_progress'] + 1 in eps:
802
846
  newep.append(show)
803
847
 
804
848
  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)