trackma 0.7__py3.4.egg → 0.7.3__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 +1 -0
- EGG-INFO/entry_points.txt +1 -1
- EGG-INFO/requires.txt +0 -2
- trackma/__pycache__/data.cpython-34.pyc +0 -0
- trackma/__pycache__/engine.cpython-34.pyc +0 -0
- trackma/__pycache__/utils.cpython-34.pyc +0 -0
- trackma/engine.py +8 -1
- 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 +1 -1
- trackma/lib/libkitsu.py +39 -10
- trackma/tracker/__pycache__/inotify.cpython-34.pyc +0 -0
- trackma/tracker/__pycache__/inotifyBase.cpython-34.pyc +0 -0
- trackma/tracker/__pycache__/plex.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/inotify.py +2 -56
- trackma/tracker/inotifyBase.py +107 -0
- trackma/tracker/plex.py +21 -12
- trackma/tracker/pyinotify.py +7 -60
- trackma/tracker/tracker.py +14 -4
- 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 +1 -1
- trackma/ui/curses.py +1 -1
- trackma/ui/gtkui.py +46 -16
- trackma/ui/qt4ui.py +6 -1
- trackma/ui/qtui.py +69 -17
- trackma/utils.py +2 -1
EGG-INFO/PKG-INFO
CHANGED
EGG-INFO/SOURCES.txt
CHANGED
EGG-INFO/entry_points.txt
CHANGED
EGG-INFO/requires.txt
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
trackma/engine.py
CHANGED
|
@@ -152,7 +152,10 @@ class Engine:
|
|
|
152
152
|
if self.config['tracker_update_prompt']:
|
|
153
153
|
self._emit_signal('prompt_for_update', show, episode)
|
|
154
154
|
else:
|
|
155
|
-
|
|
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))
|
|
156
159
|
|
|
157
160
|
def _tracker_unrecognised(self, show_title, episode):
|
|
158
161
|
if self.config['tracker_not_found_prompt']:
|
|
@@ -190,6 +193,7 @@ class Engine:
|
|
|
190
193
|
tracker_list.append({'id': show['id'],
|
|
191
194
|
'title': show['title'],
|
|
192
195
|
'my_progress': show['my_progress'],
|
|
196
|
+
'total': show['total'],
|
|
193
197
|
'type': None,
|
|
194
198
|
'titles': self.data_handler.get_show_titles(show),
|
|
195
199
|
}) # TODO types
|
|
@@ -692,6 +696,9 @@ class Engine:
|
|
|
692
696
|
return best_candidate[0], best_candidate[2]
|
|
693
697
|
|
|
694
698
|
def get_new_episodes(self, showlist):
|
|
699
|
+
# DEPRECATED !
|
|
700
|
+
self.msg.debug(self.name, "DEPRECATED: get_new_episodes")
|
|
701
|
+
|
|
695
702
|
results = list()
|
|
696
703
|
total = len(showlist)
|
|
697
704
|
t = time.time()
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
trackma/lib/libanilist.py
CHANGED
|
@@ -304,7 +304,7 @@ class libanilist(lib):
|
|
|
304
304
|
|
|
305
305
|
self.msg.info(self.name, "Searching for {}...".format(criteria))
|
|
306
306
|
param = {'access_token': self._get_userconfig('access_token')}
|
|
307
|
-
data = self._request("GET", "{0}/search/{1}".format(self.mediatype, criteria), get=param)
|
|
307
|
+
data = self._request("GET", "{0}/search/{1}".format(self.mediatype, urllib.parse.quote_plus(criteria)), get=param)
|
|
308
308
|
|
|
309
309
|
if type(data) == dict:
|
|
310
310
|
# In case of error API returns a small JSON payload
|
trackma/lib/libkitsu.py
CHANGED
|
@@ -273,7 +273,7 @@ class libkitsu(lib):
|
|
|
273
273
|
#"include": self.mediatype, # TODO : This returns a 500 for some reason.
|
|
274
274
|
"include": "media",
|
|
275
275
|
# TODO : List for manga should be different
|
|
276
|
-
"fields[anime]": "id,slug,canonicalTitle,titles,episodeCount,synopsis,subtype,posterImage",
|
|
276
|
+
"fields[anime]": "id,slug,canonicalTitle,titles,episodeCount,synopsis,subtype,posterImage,startDate,endDate",
|
|
277
277
|
"page[limit]": "250",
|
|
278
278
|
}
|
|
279
279
|
|
|
@@ -329,8 +329,13 @@ class libkitsu(lib):
|
|
|
329
329
|
show['url'] = info['url']
|
|
330
330
|
show['total'] = info['total']
|
|
331
331
|
show['image'] = info['image']
|
|
332
|
+
|
|
332
333
|
show['image_thumb'] = info['image_thumb']
|
|
333
334
|
|
|
335
|
+
show['start_date'] = info['start_date']
|
|
336
|
+
show['end_date'] = info['end_date']
|
|
337
|
+
show['status'] = info['status']
|
|
338
|
+
|
|
334
339
|
def request_info(self, item_list):
|
|
335
340
|
print("These are missing: " + repr(item_list))
|
|
336
341
|
# TODO implement
|
|
@@ -433,14 +438,31 @@ class libkitsu(lib):
|
|
|
433
438
|
return json.dumps(values)
|
|
434
439
|
|
|
435
440
|
def _str2date(self, string):
|
|
436
|
-
if string
|
|
437
|
-
try:
|
|
438
|
-
return datetime.datetime.strptime(string, "%Y-%m-%d")
|
|
439
|
-
except:
|
|
440
|
-
return None # Ignore date if it's invalid
|
|
441
|
-
else:
|
|
441
|
+
if string is None:
|
|
442
442
|
return None
|
|
443
443
|
|
|
444
|
+
try:
|
|
445
|
+
return datetime.datetime.strptime(string, "%Y-%m-%d")
|
|
446
|
+
except:
|
|
447
|
+
self.msg.debug(self.name, 'Invalid date {}'.format(string))
|
|
448
|
+
return None # Ignore date if it's invalid
|
|
449
|
+
|
|
450
|
+
def _guess_status(self, start_date, end_date):
|
|
451
|
+
# Try to guess show status by checking start and end dates
|
|
452
|
+
now = datetime.datetime.now()
|
|
453
|
+
|
|
454
|
+
if end_date and end_date < now:
|
|
455
|
+
return utils.STATUS_FINISHED
|
|
456
|
+
|
|
457
|
+
if start_date:
|
|
458
|
+
if start_date > now:
|
|
459
|
+
return utils.STATUS_NOTYET
|
|
460
|
+
else:
|
|
461
|
+
return utils.STATUS_AIRING
|
|
462
|
+
|
|
463
|
+
# Safe to assume dates haven't even been announced yet
|
|
464
|
+
return utils.STATUS_NOTYET
|
|
465
|
+
|
|
444
466
|
def _parse_info(self, media):
|
|
445
467
|
info = utils.show()
|
|
446
468
|
attr = media['attributes']
|
|
@@ -450,13 +472,10 @@ class libkitsu(lib):
|
|
|
450
472
|
|
|
451
473
|
if media['type'] == 'anime':
|
|
452
474
|
total = attr['episodeCount']
|
|
453
|
-
type_str = 'showType'
|
|
454
475
|
elif media['type'] == 'manga':
|
|
455
476
|
total = attr['chapterCount']
|
|
456
|
-
type_str = 'mangaType'
|
|
457
477
|
elif media['type'] == 'drama':
|
|
458
478
|
total = attr['episodeCount'] # TODO Unconfirmed
|
|
459
|
-
type_str = 'dramaType'
|
|
460
479
|
|
|
461
480
|
info.update({
|
|
462
481
|
'id': int(media['id']),
|
|
@@ -466,6 +485,8 @@ class libkitsu(lib):
|
|
|
466
485
|
'total': total or 0,
|
|
467
486
|
'image': attr['posterImage']['small'],
|
|
468
487
|
'image_thumb': attr['posterImage']['tiny'],
|
|
488
|
+
'start_date': self._str2date(attr['startDate']),
|
|
489
|
+
'end_date': self._str2date(attr['endDate']),
|
|
469
490
|
'url': "https://kitsu.io/{}/{}".format(self.mediatype, attr['slug']),
|
|
470
491
|
'aliases': list(filter(None, attr['titles'].values())),
|
|
471
492
|
'extra': [
|
|
@@ -474,5 +495,13 @@ class libkitsu(lib):
|
|
|
474
495
|
]
|
|
475
496
|
})
|
|
476
497
|
|
|
498
|
+
# WORKAROUND: Shows with 1 episode (TVs, SPs, OVAs) end the same day they start
|
|
499
|
+
if total == 1:
|
|
500
|
+
info['end_date'] = info['start_date']
|
|
501
|
+
|
|
502
|
+
# WORKAROUND: Since there's no way to get the formal status,
|
|
503
|
+
# use the helper function to guess it.
|
|
504
|
+
info['status'] = self._guess_status(info['start_date'], info['end_date'])
|
|
505
|
+
|
|
477
506
|
return info
|
|
478
507
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
trackma/tracker/inotify.py
CHANGED
|
@@ -14,69 +14,15 @@
|
|
|
14
14
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
15
15
|
#
|
|
16
16
|
|
|
17
|
-
import os
|
|
18
|
-
import re
|
|
19
17
|
|
|
20
18
|
import inotify.adapters
|
|
21
19
|
import inotify.constants
|
|
22
20
|
|
|
23
|
-
from trackma.tracker import
|
|
21
|
+
from trackma.tracker import inotifyBase
|
|
24
22
|
from trackma import utils
|
|
25
23
|
|
|
26
|
-
class inotifyTracker(
|
|
24
|
+
class inotifyTracker(inotifyBase.inotifyBase):
|
|
27
25
|
name = 'Tracker (inotify)'
|
|
28
|
-
open_pathname = None
|
|
29
|
-
|
|
30
|
-
def __init__(self, messenger, tracker_list, process_name, watch_dir, interval, update_wait, update_close, not_found_prompt):
|
|
31
|
-
super().__init__(messenger, tracker_list, process_name, watch_dir, interval, update_wait, update_close, not_found_prompt)
|
|
32
|
-
|
|
33
|
-
self.re_players = re.compile(self.process_name.encode('utf-8'))
|
|
34
|
-
|
|
35
|
-
def _is_being_played(self, filename):
|
|
36
|
-
"""
|
|
37
|
-
This function makes sure that the filename is being played
|
|
38
|
-
by the player specified in players.
|
|
39
|
-
|
|
40
|
-
It uses procfs so if we're using inotify that means we're using Linux
|
|
41
|
-
thus we should be safe.
|
|
42
|
-
"""
|
|
43
|
-
|
|
44
|
-
for p in os.listdir("/proc/"):
|
|
45
|
-
if not p.isdigit(): continue
|
|
46
|
-
d = "/proc/%s/fd/" % p
|
|
47
|
-
try:
|
|
48
|
-
for fd in os.listdir(d):
|
|
49
|
-
f = os.readlink(d+fd)
|
|
50
|
-
if f == filename:
|
|
51
|
-
# Get process name
|
|
52
|
-
with open('/proc/%s/cmdline' % p, 'rb') as f:
|
|
53
|
-
pname = f.read()
|
|
54
|
-
|
|
55
|
-
# Check if it's our process
|
|
56
|
-
if self.re_players.match(pname):
|
|
57
|
-
return True
|
|
58
|
-
except OSError:
|
|
59
|
-
pass
|
|
60
|
-
|
|
61
|
-
return False
|
|
62
|
-
|
|
63
|
-
def _proc_open(self, path, filename):
|
|
64
|
-
pathname = "/".join([path, filename])
|
|
65
|
-
|
|
66
|
-
if self._is_being_played(pathname):
|
|
67
|
-
self.open_pathname = pathname
|
|
68
|
-
|
|
69
|
-
(state, show_tuple) = self._get_playing_show(filename)
|
|
70
|
-
self.update_show_if_needed(state, show_tuple)
|
|
71
|
-
|
|
72
|
-
def _proc_close(self, path, filename):
|
|
73
|
-
pathname = "/".join([path, filename])
|
|
74
|
-
|
|
75
|
-
if pathname == self.open_pathname:
|
|
76
|
-
self.open_pathname = None
|
|
77
|
-
|
|
78
|
-
(state, show_tuple) = self._get_playing_show(None)
|
|
79
|
-
self.update_show_if_needed(state, show_tuple)
|
|
80
26
|
|
|
81
27
|
def observe(self, watch_dir, interval):
|
|
82
28
|
# Note that this lib uses bytestrings for filenames and paths.
|
|
@@ -0,0 +1,107 @@
|
|
|
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 os
|
|
18
|
+
import re
|
|
19
|
+
import time
|
|
20
|
+
|
|
21
|
+
from trackma.tracker import tracker
|
|
22
|
+
from trackma import utils
|
|
23
|
+
|
|
24
|
+
class inotifyBase(tracker.TrackerBase):
|
|
25
|
+
open_file = (None, None, None)
|
|
26
|
+
|
|
27
|
+
def __init__(self, messenger, tracker_list, process_name, watch_dir, interval, update_wait, update_close, not_found_prompt):
|
|
28
|
+
super().__init__(messenger, tracker_list, process_name, watch_dir, interval, update_wait, update_close, not_found_prompt)
|
|
29
|
+
|
|
30
|
+
self.re_players = re.compile(self.process_name.encode('utf-8'))
|
|
31
|
+
|
|
32
|
+
def _is_being_played(self, filename):
|
|
33
|
+
"""
|
|
34
|
+
This function makes sure that the filename is being played
|
|
35
|
+
by the player specified in players.
|
|
36
|
+
|
|
37
|
+
It uses procfs so if we're using inotify that means we're using Linux
|
|
38
|
+
thus we should be safe.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
time.sleep(0.01)
|
|
42
|
+
for p in os.listdir("/proc/"):
|
|
43
|
+
if not p.isdigit(): continue
|
|
44
|
+
d = "/proc/%s/fd/" % p
|
|
45
|
+
try:
|
|
46
|
+
for fd in os.listdir(d):
|
|
47
|
+
f = os.readlink(d+fd)
|
|
48
|
+
if f == filename:
|
|
49
|
+
# Get process name
|
|
50
|
+
with open('/proc/%s/cmdline' % p, 'rb') as f:
|
|
51
|
+
cmdline = f.read()
|
|
52
|
+
pname = cmdline.partition(b'\x00')[0]
|
|
53
|
+
self.msg.debug(self.name, 'Playing process: {} {} ({})'.format(p, pname, cmdline))
|
|
54
|
+
|
|
55
|
+
# Check if it's our process
|
|
56
|
+
if self.re_players.search(pname):
|
|
57
|
+
return p, fd
|
|
58
|
+
else:
|
|
59
|
+
self.msg.debug(self.name, "Not read by player ({})".format(pname))
|
|
60
|
+
except OSError:
|
|
61
|
+
pass
|
|
62
|
+
|
|
63
|
+
self.msg.debug(self.name, "Couldn't find playing process.")
|
|
64
|
+
return None, None
|
|
65
|
+
|
|
66
|
+
def _closed_handle(self, pid, fd):
|
|
67
|
+
""" Check if this pid has closed this handle (or never opened it) """
|
|
68
|
+
d = "/proc/%s/fd/%s" % (pid, fd)
|
|
69
|
+
time.sleep(0.01) # TODO : If we don't wait the filehandle will still be there
|
|
70
|
+
return not os.path.islink(d)
|
|
71
|
+
|
|
72
|
+
def _proc_open(self, path, name):
|
|
73
|
+
self.msg.debug(self.name, 'Got OPEN event: {} {}'.format(path, name))
|
|
74
|
+
pathname = os.path.join(path, name)
|
|
75
|
+
|
|
76
|
+
pid, fd = self._is_being_played(pathname)
|
|
77
|
+
|
|
78
|
+
if pid:
|
|
79
|
+
self._emit_signal('detected', path, name)
|
|
80
|
+
self.open_file = (pathname, pid, fd)
|
|
81
|
+
|
|
82
|
+
(state, show_tuple) = self._get_playing_show(name)
|
|
83
|
+
self.msg.debug(self.name, "Got status: {} {}".format(state, show_tuple))
|
|
84
|
+
self.update_show_if_needed(state, show_tuple)
|
|
85
|
+
else:
|
|
86
|
+
self.msg.debug(self.name, "Not played by player, ignoring.")
|
|
87
|
+
|
|
88
|
+
def _proc_close(self, path, name):
|
|
89
|
+
self.msg.debug(self.name, 'Got CLOSE event: {} {}'.format(path, name))
|
|
90
|
+
pathname = os.path.join(path, name)
|
|
91
|
+
|
|
92
|
+
open_pathname, pid, fd = self.open_file
|
|
93
|
+
|
|
94
|
+
if pathname != open_pathname:
|
|
95
|
+
self.msg.debug(self.name, "A different file was closed.")
|
|
96
|
+
return
|
|
97
|
+
|
|
98
|
+
if not self._closed_handle(pid, fd):
|
|
99
|
+
self.msg.debug(self.name, "Our pid hasn't closed the file.")
|
|
100
|
+
return
|
|
101
|
+
|
|
102
|
+
self._emit_signal('detected', path, name)
|
|
103
|
+
self.open_file = (None, None, None)
|
|
104
|
+
|
|
105
|
+
(state, show_tuple) = self._get_playing_show(None)
|
|
106
|
+
self.update_show_if_needed(state, show_tuple)
|
|
107
|
+
|
trackma/tracker/plex.py
CHANGED
|
@@ -32,6 +32,9 @@ class PlexTracker(tracker.TrackerBase):
|
|
|
32
32
|
|
|
33
33
|
def __init__(self, messenger, tracker_list, process_name, watch_dir, interval, update_wait, update_close, not_found_prompt):
|
|
34
34
|
self.config = utils.parse_config(utils.get_root_filename('config.json'), utils.config_defaults)
|
|
35
|
+
self.host_port = self.config['plex_host']+":"+self.config['plex_port']
|
|
36
|
+
self.update_wait = update_wait
|
|
37
|
+
self.status_log = [None, None]
|
|
35
38
|
super().__init__(messenger, tracker_list, process_name, watch_dir, interval, update_wait, update_close, not_found_prompt)
|
|
36
39
|
|
|
37
40
|
def get_plex_status(self):
|
|
@@ -51,8 +54,11 @@ class PlexTracker(tracker.TrackerBase):
|
|
|
51
54
|
if self.get_plex_status() == IDLE:
|
|
52
55
|
return None
|
|
53
56
|
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
meta = self._get_xml_info("Video", "key")
|
|
58
|
+
meta_url = "http://"+self.host_port+meta
|
|
59
|
+
mdoc = xdmd.parse(urllib.request.urlopen(meta_url))
|
|
60
|
+
mres = mdoc.getElementsByTagName("Part")[0].getAttribute("file")
|
|
61
|
+
name = urllib.parse.unquote(ntpath.basename(mres))
|
|
56
62
|
|
|
57
63
|
return name
|
|
58
64
|
|
|
@@ -70,28 +76,31 @@ class PlexTracker(tracker.TrackerBase):
|
|
|
70
76
|
self.msg.info(self.name, "Using Plex.")
|
|
71
77
|
|
|
72
78
|
while self.active:
|
|
73
|
-
|
|
79
|
+
self.status_log.append(self.get_plex_status())
|
|
74
80
|
|
|
75
|
-
if
|
|
76
|
-
if
|
|
77
|
-
self.msg.info(self.name, "
|
|
81
|
+
if self.status_log[-1] == ACTIVE or self.status_log[-1] == IDLE:
|
|
82
|
+
if self.status_log[-1] == IDLE and self.status_log[-2] == NOT_RUNNING:
|
|
83
|
+
self.msg.info(self.name, "Reconnected to Plex.")
|
|
84
|
+
|
|
85
|
+
if self.config['plex_obey_update_wait_s']:
|
|
86
|
+
self.wait_s = self.update_wait
|
|
87
|
+
else:
|
|
88
|
+
self.wait_s = self.timer_from_file()
|
|
78
89
|
|
|
79
|
-
self.wait_s = self.timer_from_file()
|
|
80
90
|
filename = self.playing_file()
|
|
81
91
|
(state, show_tuple) = self._get_playing_show(filename)
|
|
82
92
|
self.update_show_if_needed(state, show_tuple)
|
|
83
|
-
|
|
84
|
-
elif status == NOT_RUNNING:
|
|
93
|
+
elif self.status_log[-1] == NOT_RUNNING and self.status_log[-2] == NOT_RUNNING:
|
|
85
94
|
self.msg.warn(self.name, "Plex Media Server is not running.")
|
|
95
|
+
|
|
96
|
+
del self.status_log[0]
|
|
86
97
|
|
|
87
98
|
# Wait for the interval before running check again
|
|
88
99
|
time.sleep(interval)
|
|
89
100
|
|
|
90
101
|
def _get_xml_info(self, tag, attr):
|
|
91
102
|
# Get the required info from the /status/sessions url
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
session_url = "http://"+host_port+"/status/sessions"
|
|
103
|
+
session_url = "http://"+self.host_port+"/status/sessions"
|
|
95
104
|
sdoc = xdmd.parse(urllib.request.urlopen(session_url))
|
|
96
105
|
|
|
97
106
|
res = sdoc.getElementsByTagName(tag)[0].getAttribute(attr)
|
trackma/tracker/pyinotify.py
CHANGED
|
@@ -16,64 +16,12 @@
|
|
|
16
16
|
|
|
17
17
|
import pyinotify
|
|
18
18
|
|
|
19
|
-
import
|
|
20
|
-
import re
|
|
21
|
-
|
|
22
|
-
from trackma.tracker import tracker
|
|
19
|
+
from trackma.tracker import inotifyBase
|
|
23
20
|
from trackma import utils
|
|
24
21
|
|
|
25
|
-
class pyinotifyTracker(
|
|
22
|
+
class pyinotifyTracker(inotifyBase.inotifyBase):
|
|
26
23
|
name = 'Tracker (pyinotify)'
|
|
27
24
|
|
|
28
|
-
open_pathname = None
|
|
29
|
-
|
|
30
|
-
def __init__(self, messenger, tracker_list, process_name, watch_dir, interval, update_wait, update_close, not_found_prompt):
|
|
31
|
-
super().__init__(messenger, tracker_list, process_name, watch_dir, interval, update_wait, update_close, not_found_prompt)
|
|
32
|
-
|
|
33
|
-
self.re_players = re.compile(self.process_name.encode('utf-8'))
|
|
34
|
-
|
|
35
|
-
def _is_being_played(self, filename):
|
|
36
|
-
"""
|
|
37
|
-
This function makes sure that the filename is being played
|
|
38
|
-
by the player specified in players.
|
|
39
|
-
|
|
40
|
-
It uses procfs so if we're using inotify that means we're using Linux
|
|
41
|
-
thus we should be safe.
|
|
42
|
-
"""
|
|
43
|
-
|
|
44
|
-
for p in os.listdir("/proc/"):
|
|
45
|
-
if not p.isdigit(): continue
|
|
46
|
-
d = "/proc/%s/fd/" % p
|
|
47
|
-
try:
|
|
48
|
-
for fd in os.listdir(d):
|
|
49
|
-
f = os.readlink(d+fd)
|
|
50
|
-
if f == filename:
|
|
51
|
-
# Get process name
|
|
52
|
-
with open('/proc/%s/cmdline' % p, 'rb') as f:
|
|
53
|
-
pname = f.read()
|
|
54
|
-
|
|
55
|
-
# Check if it's our process
|
|
56
|
-
if self.re_players.match(pname):
|
|
57
|
-
return True
|
|
58
|
-
except OSError:
|
|
59
|
-
pass
|
|
60
|
-
|
|
61
|
-
return False
|
|
62
|
-
|
|
63
|
-
def _proc_open(self, pathname, filename):
|
|
64
|
-
if self._is_being_played(pathname):
|
|
65
|
-
self.open_pathname = pathname
|
|
66
|
-
|
|
67
|
-
(state, show_tuple) = self._get_playing_show(filename)
|
|
68
|
-
self.update_show_if_needed(state, show_tuple)
|
|
69
|
-
|
|
70
|
-
def _proc_close(self, pathname):
|
|
71
|
-
if pathname == self.open_pathname:
|
|
72
|
-
self.open_pathname = None
|
|
73
|
-
|
|
74
|
-
(state, show_tuple) = self._get_playing_show(None)
|
|
75
|
-
self.update_show_if_needed(state, show_tuple)
|
|
76
|
-
|
|
77
25
|
def observe(self, watch_dir, interval):
|
|
78
26
|
self.msg.info(self.name, 'Using pyinotify.')
|
|
79
27
|
wm = pyinotify.WatchManager() # Watch Manager
|
|
@@ -91,18 +39,15 @@ class pyinotifyTracker(tracker.TrackerBase):
|
|
|
91
39
|
|
|
92
40
|
def process_IN_OPEN(self, event):
|
|
93
41
|
if not event.mask & pyinotify.IN_ISDIR:
|
|
94
|
-
self.parent.
|
|
95
|
-
self.parent._proc_open(event.pathname, event.name)
|
|
42
|
+
self.parent._proc_open(event.path, event.name)
|
|
96
43
|
|
|
97
44
|
def process_IN_CLOSE_NOWRITE(self, event):
|
|
98
45
|
if not event.mask & pyinotify.IN_ISDIR:
|
|
99
|
-
self.parent.
|
|
100
|
-
self.parent._proc_close(event.pathname)
|
|
46
|
+
self.parent._proc_close(event.path, event.name)
|
|
101
47
|
|
|
102
48
|
def process_IN_CLOSE_WRITE(self, event):
|
|
103
49
|
if not event.mask & pyinotify.IN_ISDIR:
|
|
104
|
-
self.parent.
|
|
105
|
-
self.parent._proc_close(event.pathname)
|
|
50
|
+
self.parent._proc_close(event.path, event.name)
|
|
106
51
|
|
|
107
52
|
def process_IN_CREATE(self, event):
|
|
108
53
|
if not event.mask & pyinotify.IN_ISDIR:
|
|
@@ -122,6 +67,7 @@ class pyinotifyTracker(tracker.TrackerBase):
|
|
|
122
67
|
|
|
123
68
|
handler = EventHandler(parent=self)
|
|
124
69
|
notifier = pyinotify.Notifier(wm, handler)
|
|
70
|
+
self.msg.debug(self.name, 'Watching directory {}'.format(watch_dir))
|
|
125
71
|
wdd = wm.add_watch(watch_dir, mask, rec=True, auto_add=True)
|
|
126
72
|
|
|
127
73
|
try:
|
|
@@ -136,6 +82,7 @@ class pyinotifyTracker(tracker.TrackerBase):
|
|
|
136
82
|
else:
|
|
137
83
|
timeout = 1000 # Check each second for counting
|
|
138
84
|
else:
|
|
85
|
+
self.msg.debug(self.name, "Sending last state {} {}".format(self.last_state, self.last_show_tuple))
|
|
139
86
|
self.update_show_if_needed(self.last_state, self.last_show_tuple)
|
|
140
87
|
finally:
|
|
141
88
|
notifier.stop()
|
trackma/tracker/tracker.py
CHANGED
|
@@ -121,6 +121,13 @@ class TrackerBase(object):
|
|
|
121
121
|
elif action:
|
|
122
122
|
action()
|
|
123
123
|
|
|
124
|
+
def _ignore_current(self):
|
|
125
|
+
# Stops attempt to update current episode
|
|
126
|
+
self.last_updated = True
|
|
127
|
+
self.last_state = utils.TRACKER_IGNORED
|
|
128
|
+
self.timer = None
|
|
129
|
+
self._emit_signal('state', utils.TRACKER_IGNORED, None)
|
|
130
|
+
|
|
124
131
|
def _update_state(self, state):
|
|
125
132
|
# Call when show or state is changed. Perform queued update if any, and clear playing flag.
|
|
126
133
|
if self.last_close_queue:
|
|
@@ -142,14 +149,17 @@ class TrackerBase(object):
|
|
|
142
149
|
self._update_state(state)
|
|
143
150
|
# There's a new show/ep detected, so let's save the show information
|
|
144
151
|
self.last_show_tuple = show_tuple
|
|
152
|
+
self.last_updated = False
|
|
145
153
|
if state == utils.TRACKER_PLAYING:
|
|
146
154
|
self._emit_signal('playing', show['id'], True, episode)
|
|
147
155
|
# Check if we shouldn't update the show
|
|
148
156
|
if episode != (show['my_progress'] + 1):
|
|
149
|
-
self.msg.warn(self.name, '
|
|
150
|
-
self.
|
|
151
|
-
|
|
152
|
-
|
|
157
|
+
self.msg.warn(self.name, 'Not playing the next episode of %s. Ignoring.' % show['title'])
|
|
158
|
+
self._ignore_current()
|
|
159
|
+
return
|
|
160
|
+
if episode < 1 or (show['total'] and episode > show['total']):
|
|
161
|
+
self.msg.warn(self.name, 'Playing an invalid episode of %s. Ignoring.' % show['title'])
|
|
162
|
+
self._ignore_current()
|
|
153
163
|
return
|
|
154
164
|
|
|
155
165
|
# Start our countdown
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
trackma/ui/cli.py
CHANGED
|
@@ -830,7 +830,7 @@ class Trackma_cmd(cmd.Cmd):
|
|
|
830
830
|
# List shows
|
|
831
831
|
for index, show in showlist:
|
|
832
832
|
if self.engine.mediainfo['has_progress']:
|
|
833
|
-
episodes_str = "{0:3} / {1}".format(show['my_progress'], show['total'])
|
|
833
|
+
episodes_str = "{0:3} / {1}".format(show['my_progress'], show['total'] or '?')
|
|
834
834
|
else:
|
|
835
835
|
episodes_str = "-"
|
|
836
836
|
|
trackma/ui/curses.py
CHANGED
|
@@ -1003,7 +1003,7 @@ class ShowWalker(urwid.SimpleListWalker):
|
|
|
1003
1003
|
class ShowItem(urwid.WidgetWrap):
|
|
1004
1004
|
def __init__(self, show, has_progress=True, altname=None, eps=None):
|
|
1005
1005
|
if has_progress:
|
|
1006
|
-
self.episodes_str = urwid.Text("{0:3} / {1}".format(show['my_progress'], show['total']))
|
|
1006
|
+
self.episodes_str = urwid.Text("{0:3} / {1}".format(show['my_progress'], show['total'] or '?'))
|
|
1007
1007
|
else:
|
|
1008
1008
|
self.episodes_str = urwid.Text("-")
|
|
1009
1009
|
|
trackma/ui/gtkui.py
CHANGED
|
@@ -1754,7 +1754,7 @@ class InfoWidget(Gtk.VBox):
|
|
|
1754
1754
|
self.w_image.image_show(imagefile)
|
|
1755
1755
|
else:
|
|
1756
1756
|
self.w_image.pholder_show('Loading...')
|
|
1757
|
-
self.image_thread = ImageTask(self.w_image, show['image'], imagefile)
|
|
1757
|
+
self.image_thread = ImageTask(self.w_image, show['image'], imagefile, (200, 298))
|
|
1758
1758
|
self.image_thread.start()
|
|
1759
1759
|
|
|
1760
1760
|
# Start info loading thread
|
|
@@ -1827,7 +1827,7 @@ class Settings(Gtk.Window):
|
|
|
1827
1827
|
line0.pack_start(lbl_player, False, False, 5)
|
|
1828
1828
|
line0.pack_start(self.txt_player, True, True, 0)
|
|
1829
1829
|
line0.pack_start(playerbrowse_button, False, False, 0)
|
|
1830
|
-
|
|
1830
|
+
|
|
1831
1831
|
### Tracker ###
|
|
1832
1832
|
|
|
1833
1833
|
# Labels
|
|
@@ -1840,9 +1840,6 @@ class Settings(Gtk.Window):
|
|
|
1840
1840
|
lbl_tracker_enabled = Gtk.Label('Enable Tracker')
|
|
1841
1841
|
lbl_tracker_enabled.set_size_request(120, -1)
|
|
1842
1842
|
lbl_tracker_enabled.set_xalign(0)
|
|
1843
|
-
lbl_tracker_plex_host_port = Gtk.Label('Host and Port')
|
|
1844
|
-
lbl_tracker_plex_host_port.set_size_request(120, -1)
|
|
1845
|
-
lbl_tracker_plex_host_port.set_xalign(0)
|
|
1846
1843
|
lbl_tracker_update_wait = Gtk.Label('Wait before update')
|
|
1847
1844
|
lbl_tracker_update_wait.set_size_request(120, -1)
|
|
1848
1845
|
lbl_tracker_update_wait.set_xalign(0)
|
|
@@ -1858,11 +1855,6 @@ class Settings(Gtk.Window):
|
|
|
1858
1855
|
self.browse_button = Gtk.Button('Browse...')
|
|
1859
1856
|
self.browse_button.connect("clicked", self.__do_browse, 'Select search directory', self.txt_searchdir, True)
|
|
1860
1857
|
self.chk_tracker_enabled = Gtk.CheckButton()
|
|
1861
|
-
self.txt_plex_host = Gtk.Entry()
|
|
1862
|
-
self.txt_plex_host.set_max_length(4096)
|
|
1863
|
-
self.txt_plex_port = Gtk.Entry()
|
|
1864
|
-
self.txt_plex_port.set_max_length(5)
|
|
1865
|
-
self.txt_plex_port.set_width_chars(5)
|
|
1866
1858
|
self.chk_tracker_enabled.connect("toggled", self.tracker_type_sensitive)
|
|
1867
1859
|
self.spin_tracker_update_wait = Gtk.SpinButton()
|
|
1868
1860
|
self.spin_tracker_update_wait.set_adjustment(Gtk.Adjustment(value=5, lower=0, upper=500, step_incr=1, page_incr=10))
|
|
@@ -1901,11 +1893,6 @@ class Settings(Gtk.Window):
|
|
|
1901
1893
|
line2.pack_start(lbl_process, False, False, 5)
|
|
1902
1894
|
line2.pack_start(self.txt_process, True, True, 0)
|
|
1903
1895
|
|
|
1904
|
-
line7 = Gtk.HBox(False, 5)
|
|
1905
|
-
line7.pack_start(lbl_tracker_plex_host_port, False, False, 5)
|
|
1906
|
-
line7.pack_start(self.txt_plex_host, True, True, 0)
|
|
1907
|
-
line7.pack_start(self.txt_plex_port, True, True, 0)
|
|
1908
|
-
|
|
1909
1896
|
line3 = Gtk.HBox(False, 5)
|
|
1910
1897
|
line3.pack_start(lbl_tracker_enabled, False, False, 5)
|
|
1911
1898
|
line3.pack_start(self.chk_tracker_enabled, False, False, 0)
|
|
@@ -1921,6 +1908,37 @@ class Settings(Gtk.Window):
|
|
|
1921
1908
|
line9.pack_start(lbl_tracker_update_options, False, False, 5)
|
|
1922
1909
|
line9.pack_start(self.chk_tracker_update_close, False, False, 0)
|
|
1923
1910
|
line9.pack_start(self.chk_tracker_update_prompt, False, False, 0)
|
|
1911
|
+
|
|
1912
|
+
### Plex ###
|
|
1913
|
+
header6 = Gtk.Label()
|
|
1914
|
+
header6.set_text('<b>Plex Media Server</b>')
|
|
1915
|
+
header6.set_use_markup(True)
|
|
1916
|
+
header6.set_xalign(0)
|
|
1917
|
+
|
|
1918
|
+
# Labels
|
|
1919
|
+
lbl_tracker_plex_host_port = Gtk.Label('Host and Port')
|
|
1920
|
+
lbl_tracker_plex_host_port.set_size_request(120, -1)
|
|
1921
|
+
lbl_tracker_plex_host_port.set_xalign(0)
|
|
1922
|
+
lbl_tracker_plex_obey_wait = Gtk.Label('Use "wait before update" time')
|
|
1923
|
+
lbl_tracker_plex_obey_wait.set_size_request(120, -1)
|
|
1924
|
+
lbl_tracker_plex_obey_wait.set_xalign(0)
|
|
1925
|
+
|
|
1926
|
+
# Entries
|
|
1927
|
+
self.txt_plex_host = Gtk.Entry()
|
|
1928
|
+
self.txt_plex_host.set_max_length(4096)
|
|
1929
|
+
self.txt_plex_port = Gtk.Entry()
|
|
1930
|
+
self.txt_plex_port.set_max_length(5)
|
|
1931
|
+
self.txt_plex_port.set_width_chars(5)
|
|
1932
|
+
self.chk_tracker_plex_obey_wait = Gtk.CheckButton()
|
|
1933
|
+
|
|
1934
|
+
# HBoxes
|
|
1935
|
+
line7 = Gtk.HBox(False, 5)
|
|
1936
|
+
line7.pack_start(lbl_tracker_plex_host_port, False, False, 5)
|
|
1937
|
+
line7.pack_start(self.txt_plex_host, True, True, 0)
|
|
1938
|
+
line7.pack_start(self.txt_plex_port, True, True, 0)
|
|
1939
|
+
line10 = Gtk.HBox(False, 5)
|
|
1940
|
+
line10.pack_start(lbl_tracker_plex_obey_wait, False, False, 5)
|
|
1941
|
+
line10.pack_start(self.chk_tracker_plex_obey_wait, False, False, 0)
|
|
1924
1942
|
|
|
1925
1943
|
### Auto-retrieve ###
|
|
1926
1944
|
header2 = Gtk.Label()
|
|
@@ -2090,9 +2108,11 @@ class Settings(Gtk.Window):
|
|
|
2090
2108
|
page0.pack_start(line3, False, False, 0)
|
|
2091
2109
|
page0.pack_start(line1, False, False, 0)
|
|
2092
2110
|
page0.pack_start(line2, False, False, 0)
|
|
2093
|
-
page0.pack_start(line7, False, False, 0)
|
|
2094
2111
|
page0.pack_start(line8, False, False, 0)
|
|
2095
2112
|
page0.pack_start(line9, False, False, 0)
|
|
2113
|
+
page0.pack_start(header6, False, False, 0)
|
|
2114
|
+
page0.pack_start(line7, False, False, 0)
|
|
2115
|
+
page0.pack_start(line10, False, False, 0)
|
|
2096
2116
|
|
|
2097
2117
|
page1 = Gtk.VBox(False, 10)
|
|
2098
2118
|
page1.set_border_width(10)
|
|
@@ -2126,6 +2146,7 @@ class Settings(Gtk.Window):
|
|
|
2126
2146
|
self.txt_searchdir.set_text(self.engine.get_config('searchdir'))
|
|
2127
2147
|
self.txt_plex_host.set_text(self.engine.get_config('plex_host'))
|
|
2128
2148
|
self.txt_plex_port.set_text(self.engine.get_config('plex_port'))
|
|
2149
|
+
self.chk_tracker_plex_obey_wait.set_active(self.engine.get_config('plex_obey_update_wait_s'))
|
|
2129
2150
|
self.chk_tracker_enabled.set_active(self.engine.get_config('tracker_enabled'))
|
|
2130
2151
|
self.rbtn_autosend_at_exit.set_active(self.engine.get_config('autosend_at_exit'))
|
|
2131
2152
|
self.spin_tracker_update_wait.set_value(self.engine.get_config('tracker_update_wait_s'))
|
|
@@ -2136,6 +2157,7 @@ class Settings(Gtk.Window):
|
|
|
2136
2157
|
self.rbtn_tracker_local.set_active(True)
|
|
2137
2158
|
self.txt_plex_host.set_sensitive(False)
|
|
2138
2159
|
self.txt_plex_port.set_sensitive(False)
|
|
2160
|
+
self.chk_tracker_plex_obey_wait.set_sensitive(False)
|
|
2139
2161
|
elif self.engine.get_config('tracker_type') == 'plex':
|
|
2140
2162
|
self.rbtn_tracker_plex.set_active(True)
|
|
2141
2163
|
self.txt_process.set_sensitive(False)
|
|
@@ -2175,6 +2197,7 @@ class Settings(Gtk.Window):
|
|
|
2175
2197
|
self.engine.set_config('searchdir', self.txt_searchdir.get_text())
|
|
2176
2198
|
self.engine.set_config('plex_host', self.txt_plex_host.get_text())
|
|
2177
2199
|
self.engine.set_config('plex_port', self.txt_plex_port.get_text())
|
|
2200
|
+
self.engine.set_config('plex_obey_update_wait_s', self.chk_tracker_plex_obey_wait.get_active())
|
|
2178
2201
|
self.engine.set_config('tracker_enabled', self.chk_tracker_enabled.get_active())
|
|
2179
2202
|
self.engine.set_config('autosend_at_exit', self.rbtn_autosend_at_exit.get_active())
|
|
2180
2203
|
self.engine.set_config('tracker_update_wait_s', self.spin_tracker_update_wait.get_value())
|
|
@@ -2243,9 +2266,11 @@ class Settings(Gtk.Window):
|
|
|
2243
2266
|
self.txt_process.set_sensitive(True)
|
|
2244
2267
|
self.txt_plex_host.set_sensitive(False)
|
|
2245
2268
|
self.txt_plex_port.set_sensitive(False)
|
|
2269
|
+
self.chk_tracker_plex_obey_wait.set_sensitive(False)
|
|
2246
2270
|
elif self.rbtn_tracker_plex.get_active():
|
|
2247
2271
|
self.txt_plex_host.set_sensitive(True)
|
|
2248
2272
|
self.txt_plex_port.set_sensitive(True)
|
|
2273
|
+
self.chk_tracker_plex_obey_wait.set_sensitive(True)
|
|
2249
2274
|
self.txt_process.set_sensitive(False)
|
|
2250
2275
|
self.spin_tracker_update_wait.set_sensitive(True)
|
|
2251
2276
|
else:
|
|
@@ -2253,6 +2278,7 @@ class Settings(Gtk.Window):
|
|
|
2253
2278
|
self.spin_tracker_update_wait.set_sensitive(False)
|
|
2254
2279
|
self.txt_plex_host.set_sensitive(False)
|
|
2255
2280
|
self.txt_plex_port.set_sensitive(False)
|
|
2281
|
+
self.chk_tracker_plex_obey_wait.set_sensitive(False)
|
|
2256
2282
|
|
|
2257
2283
|
def __do_browse(self, widget, title, entry, dironly=False):
|
|
2258
2284
|
browsew = Gtk.FileChooserDialog(title,
|
|
@@ -2296,9 +2322,11 @@ class AccountSelectAdd(Gtk.Window):
|
|
|
2296
2322
|
# Entries
|
|
2297
2323
|
self.txt_user = Gtk.Entry()
|
|
2298
2324
|
self.txt_user.set_max_length(128)
|
|
2325
|
+
self.txt_user.set_activates_default(True)
|
|
2299
2326
|
self.txt_passwd = Gtk.Entry()
|
|
2300
2327
|
self.txt_passwd.set_max_length(128)
|
|
2301
2328
|
self.txt_passwd.set_visibility(False)
|
|
2329
|
+
self.txt_passwd.set_activates_default(True)
|
|
2302
2330
|
|
|
2303
2331
|
# Combobox
|
|
2304
2332
|
self.model_api = Gtk.ListStore(str, str, GdkPixbuf.Pixbuf)
|
|
@@ -2322,6 +2350,8 @@ class AccountSelectAdd(Gtk.Window):
|
|
|
2322
2350
|
alignment = Gtk.Alignment(xalign=0.5, xscale=0)
|
|
2323
2351
|
bottombar = Gtk.HBox(False, 5)
|
|
2324
2352
|
self.add_button = Gtk.Button(stock=Gtk.STOCK_APPLY)
|
|
2353
|
+
self.add_button.set_can_default(True)
|
|
2354
|
+
self.add_button.grab_default()
|
|
2325
2355
|
close_button = Gtk.Button(stock=Gtk.STOCK_CLOSE)
|
|
2326
2356
|
close_button.connect("clicked", self.__do_close)
|
|
2327
2357
|
bottombar.pack_start(self.add_button, False, False, 0)
|
trackma/ui/qt4ui.py
CHANGED
trackma/ui/qtui.py
CHANGED
|
@@ -109,9 +109,11 @@ class Trackma(QMainWindow):
|
|
|
109
109
|
Main GUI class
|
|
110
110
|
|
|
111
111
|
"""
|
|
112
|
+
debug = False
|
|
112
113
|
config = None
|
|
113
114
|
tray = None
|
|
114
115
|
accountman = None
|
|
116
|
+
accountman_widget = None
|
|
115
117
|
worker = None
|
|
116
118
|
image_worker = None
|
|
117
119
|
started = False
|
|
@@ -120,8 +122,9 @@ class Trackma(QMainWindow):
|
|
|
120
122
|
finish = False
|
|
121
123
|
was_maximized = False
|
|
122
124
|
|
|
123
|
-
def __init__(self):
|
|
125
|
+
def __init__(self, debug=False):
|
|
124
126
|
QMainWindow.__init__(self, None)
|
|
127
|
+
self.debug = debug
|
|
125
128
|
|
|
126
129
|
# Load QT specific configuration
|
|
127
130
|
self.configfile = utils.get_root_filename('ui-qt.json')
|
|
@@ -141,10 +144,13 @@ class Trackma(QMainWindow):
|
|
|
141
144
|
if default:
|
|
142
145
|
self.start(default)
|
|
143
146
|
else:
|
|
144
|
-
self.
|
|
145
|
-
self.accountman_widget.selected.connect(self.accountman_selected)
|
|
147
|
+
self.accountman_create()
|
|
146
148
|
self.accountman_widget.show()
|
|
147
149
|
|
|
150
|
+
def accountman_create(self):
|
|
151
|
+
self.accountman_widget = AccountDialog(None, self.accountman)
|
|
152
|
+
self.accountman_widget.selected.connect(self.accountman_selected)
|
|
153
|
+
|
|
148
154
|
def accountman_selected(self, account_num, remember):
|
|
149
155
|
account = self.accountman.get_account(account_num)
|
|
150
156
|
|
|
@@ -480,7 +486,7 @@ class Trackma(QMainWindow):
|
|
|
480
486
|
self._tray()
|
|
481
487
|
|
|
482
488
|
# Connect worker signals
|
|
483
|
-
self.worker.changed_status.connect(self.
|
|
489
|
+
self.worker.changed_status.connect(self.ws_changed_status)
|
|
484
490
|
self.worker.raised_error.connect(self.error)
|
|
485
491
|
self.worker.raised_fatal.connect(self.fatal)
|
|
486
492
|
self.worker.changed_show.connect(self.ws_changed_show)
|
|
@@ -733,7 +739,7 @@ class Trackma(QMainWindow):
|
|
|
733
739
|
title_str = show['title']
|
|
734
740
|
if altname:
|
|
735
741
|
title_str += " [%s]" % altname
|
|
736
|
-
progress_str = "
|
|
742
|
+
progress_str = "{} / {}".format(show['my_progress'], show['total'] or '?')
|
|
737
743
|
percent_widget = EpisodeBar(self, self.config['colors'])
|
|
738
744
|
percent_widget.setRange(0, 100)
|
|
739
745
|
percent_widget.setBarStyle(self.config['episodebar_style'], self.config['episodebar_text'])
|
|
@@ -840,7 +846,7 @@ class Trackma(QMainWindow):
|
|
|
840
846
|
# Regenerate Play Episode Menu
|
|
841
847
|
self.generate_episode_menus(self.menu_play, show['total'], show['my_progress'])
|
|
842
848
|
else:
|
|
843
|
-
self.show_progress.setMaximum(utils.estimate_aired_episodes(show))
|
|
849
|
+
self.show_progress.setMaximum(utils.estimate_aired_episodes(show) or 10000)
|
|
844
850
|
self.generate_episode_menus(self.menu_play, utils.estimate_aired_episodes(show),show['my_progress'])
|
|
845
851
|
|
|
846
852
|
# Update information
|
|
@@ -1168,11 +1174,14 @@ class Trackma(QMainWindow):
|
|
|
1168
1174
|
ep_default = 1
|
|
1169
1175
|
ep_min = 1
|
|
1170
1176
|
ep_max = utils.estimate_aired_episodes(show)
|
|
1171
|
-
if ep_max
|
|
1172
|
-
|
|
1177
|
+
if not ep_max:
|
|
1178
|
+
# If we don't know the total just allow anything
|
|
1179
|
+
ep_max = show['total'] or 10000
|
|
1180
|
+
|
|
1173
1181
|
episode, ok = QInputDialog.getInt(self, 'Play Episode',
|
|
1174
1182
|
'Enter an episode number of %s to play:' % show['title'],
|
|
1175
1183
|
ep_default, ep_min, ep_max)
|
|
1184
|
+
|
|
1176
1185
|
if ok:
|
|
1177
1186
|
self.s_play(False, episode)
|
|
1178
1187
|
|
|
@@ -1210,7 +1219,7 @@ class Trackma(QMainWindow):
|
|
|
1210
1219
|
if queue:
|
|
1211
1220
|
reply = QMessageBox.question(self, 'Confirmation',
|
|
1212
1221
|
'There are %d unsynced changes. Do you want to send them first? (Choosing No will discard them!)' % len(queue),
|
|
1213
|
-
QMessageBox.Yes
|
|
1222
|
+
QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel)
|
|
1214
1223
|
|
|
1215
1224
|
if reply == QMessageBox.Yes:
|
|
1216
1225
|
self.s_send(True)
|
|
@@ -1229,6 +1238,9 @@ class Trackma(QMainWindow):
|
|
|
1229
1238
|
self.worker_call('list_upload', self.r_generic_ready)
|
|
1230
1239
|
|
|
1231
1240
|
def s_switch_account(self):
|
|
1241
|
+
if not self.accountman_widget:
|
|
1242
|
+
self.accountman_create()
|
|
1243
|
+
|
|
1232
1244
|
self.accountman_widget.setModal(True)
|
|
1233
1245
|
self.accountman_widget.show()
|
|
1234
1246
|
|
|
@@ -1302,6 +1314,12 @@ class Trackma(QMainWindow):
|
|
|
1302
1314
|
showlist.setColumnWidth(index, MIN_WIDTH)
|
|
1303
1315
|
|
|
1304
1316
|
### Worker slots
|
|
1317
|
+
def ws_changed_status(self, classname, msgtype, msg):
|
|
1318
|
+
if msgtype != messenger.TYPE_DEBUG:
|
|
1319
|
+
self.status('{}: {}'.format(classname, msg))
|
|
1320
|
+
elif self.debug:
|
|
1321
|
+
print('[D] {}: {}'.format(classname, msg))
|
|
1322
|
+
|
|
1305
1323
|
def ws_changed_show(self, show, is_playing=False, episode=None, altname=None):
|
|
1306
1324
|
if show:
|
|
1307
1325
|
if not self.show_lists:
|
|
@@ -1577,7 +1595,7 @@ class DetailsWidget(QWidget):
|
|
|
1577
1595
|
self.s_show_image(filename)
|
|
1578
1596
|
else:
|
|
1579
1597
|
self.show_image.setText('Downloading...')
|
|
1580
|
-
self.image_worker = Image_Worker(show['image'], filename)
|
|
1598
|
+
self.image_worker = Image_Worker(show['image'], filename, (200, 280))
|
|
1581
1599
|
self.image_worker.finished.connect(self.s_show_image)
|
|
1582
1600
|
self.image_worker.start()
|
|
1583
1601
|
|
|
@@ -1784,8 +1802,6 @@ class SettingsDialog(QDialog):
|
|
|
1784
1802
|
self.tracker_type_local.toggled.connect(self.tracker_type_change)
|
|
1785
1803
|
self.tracker_type_plex = QRadioButton('Plex media server')
|
|
1786
1804
|
self.tracker_type_plex.toggled.connect(self.tracker_type_change)
|
|
1787
|
-
self.plex_host = QLineEdit()
|
|
1788
|
-
self.plex_port = QLineEdit()
|
|
1789
1805
|
self.tracker_interval = QSpinBox()
|
|
1790
1806
|
self.tracker_interval.setRange(5, 1000)
|
|
1791
1807
|
self.tracker_interval.setMaximumWidth(60)
|
|
@@ -1802,8 +1818,6 @@ class SettingsDialog(QDialog):
|
|
|
1802
1818
|
g_media_layout.addRow(self.tracker_type_plex)
|
|
1803
1819
|
g_media_layout.addRow('Tracker interval (seconds)', self.tracker_interval)
|
|
1804
1820
|
g_media_layout.addRow('Process name (regex)', self.tracker_process)
|
|
1805
|
-
g_media_layout.addRow('Plex host', self.plex_host)
|
|
1806
|
-
g_media_layout.addRow('Plex port', self.plex_port)
|
|
1807
1821
|
g_media_layout.addRow('Wait before updating (seconds)', self.tracker_update_wait)
|
|
1808
1822
|
g_media_layout.addRow('Wait until the player is closed', self.tracker_update_close)
|
|
1809
1823
|
g_media_layout.addRow('Ask before updating', self.tracker_update_prompt)
|
|
@@ -1811,6 +1825,22 @@ class SettingsDialog(QDialog):
|
|
|
1811
1825
|
|
|
1812
1826
|
g_media.setLayout(g_media_layout)
|
|
1813
1827
|
|
|
1828
|
+
# Group: Plex settings
|
|
1829
|
+
g_plex = QGroupBox('Plex Media Server')
|
|
1830
|
+
g_plex.setFlat(True)
|
|
1831
|
+
self.plex_host = QLineEdit()
|
|
1832
|
+
self.plex_port = QLineEdit()
|
|
1833
|
+
self.plex_obey_wait = QCheckBox()
|
|
1834
|
+
|
|
1835
|
+
g_plex_layout = QGridLayout()
|
|
1836
|
+
g_plex_layout.addWidget(QLabel('Host and Port'), 0, 0, 1, 1)
|
|
1837
|
+
g_plex_layout.addWidget(self.plex_host, 0, 1, 1, 1)
|
|
1838
|
+
g_plex_layout.addWidget(self.plex_port, 0, 2, 1, 2)
|
|
1839
|
+
g_plex_layout.addWidget(QLabel('Use "wait before updating" time'), 1, 0, 1, 1)
|
|
1840
|
+
g_plex_layout.addWidget(self.plex_obey_wait, 1, 2, 1, 1)
|
|
1841
|
+
|
|
1842
|
+
g_plex.setLayout(g_plex_layout)
|
|
1843
|
+
|
|
1814
1844
|
# Group: Play Next
|
|
1815
1845
|
g_playnext = QGroupBox('Play Next')
|
|
1816
1846
|
g_playnext.setFlat(True)
|
|
@@ -1836,6 +1866,7 @@ class SettingsDialog(QDialog):
|
|
|
1836
1866
|
|
|
1837
1867
|
# Media form
|
|
1838
1868
|
page_media_layout.addWidget(g_media)
|
|
1869
|
+
page_media_layout.addWidget(g_plex)
|
|
1839
1870
|
page_media_layout.addWidget(g_playnext)
|
|
1840
1871
|
page_media.setLayout(page_media_layout)
|
|
1841
1872
|
|
|
@@ -2076,11 +2107,13 @@ class SettingsDialog(QDialog):
|
|
|
2076
2107
|
self.library_autoscan.setChecked(engine.get_config('library_autoscan'))
|
|
2077
2108
|
self.plex_host.setText(engine.get_config('plex_host'))
|
|
2078
2109
|
self.plex_port.setText(engine.get_config('plex_port'))
|
|
2110
|
+
self.plex_obey_wait.setChecked(engine.get_config('plex_obey_update_wait_s'))
|
|
2079
2111
|
|
|
2080
2112
|
if tracker_type == 'local':
|
|
2081
2113
|
self.tracker_type_local.setChecked(True)
|
|
2082
2114
|
self.plex_host.setEnabled(False)
|
|
2083
2115
|
self.plex_port.setEnabled(False)
|
|
2116
|
+
self.plex_obey_wait.setEnabled(False)
|
|
2084
2117
|
elif tracker_type == 'plex':
|
|
2085
2118
|
self.tracker_type_plex.setChecked(True)
|
|
2086
2119
|
self.tracker_process.setEnabled(False)
|
|
@@ -2150,6 +2183,7 @@ class SettingsDialog(QDialog):
|
|
|
2150
2183
|
engine.set_config('library_autoscan', self.library_autoscan.isChecked())
|
|
2151
2184
|
engine.set_config('plex_host', self.plex_host.text())
|
|
2152
2185
|
engine.set_config('plex_port', self.plex_port.text())
|
|
2186
|
+
engine.set_config('plex_obey_update_wait_s', self.plex_obey_wait.isChecked())
|
|
2153
2187
|
|
|
2154
2188
|
if self.tracker_type_local.isChecked():
|
|
2155
2189
|
engine.set_config('tracker_type', 'local')
|
|
@@ -2218,15 +2252,18 @@ class SettingsDialog(QDialog):
|
|
|
2218
2252
|
self.tracker_process.setEnabled(True)
|
|
2219
2253
|
self.plex_host.setEnabled(False)
|
|
2220
2254
|
self.plex_port.setEnabled(False)
|
|
2255
|
+
self.plex_obey_wait.setEnabled(False)
|
|
2221
2256
|
elif self.tracker_type_plex.isChecked():
|
|
2222
2257
|
self.plex_host.setEnabled(True)
|
|
2223
2258
|
self.plex_port.setEnabled(True)
|
|
2259
|
+
self.plex_obey_wait.setEnabled(True)
|
|
2224
2260
|
self.tracker_process.setEnabled(False)
|
|
2225
2261
|
else:
|
|
2226
2262
|
self.tracker_type_local.setEnabled(False)
|
|
2227
2263
|
self.tracker_type_plex.setEnabled(False)
|
|
2228
2264
|
self.plex_host.setEnabled(False)
|
|
2229
2265
|
self.plex_port.setEnabled(False)
|
|
2266
|
+
self.plex_obey_wait.setEnabled(False)
|
|
2230
2267
|
self.tracker_process.setEnabled(False)
|
|
2231
2268
|
self.tracker_interval.setEnabled(False)
|
|
2232
2269
|
self.tracker_update_wait.setEnabled(False)
|
|
@@ -2386,6 +2423,7 @@ class AccountDialog(QDialog):
|
|
|
2386
2423
|
self.edit_btns.activated.connect(self.s_edit)
|
|
2387
2424
|
select_btn = QPushButton('Select')
|
|
2388
2425
|
select_btn.clicked.connect(self.select)
|
|
2426
|
+
select_btn.setDefault(True)
|
|
2389
2427
|
bottom_layout.addWidget(self.remember_chk)
|
|
2390
2428
|
bottom_layout.addWidget(cancel_btn)
|
|
2391
2429
|
bottom_layout.addWidget(add_btn)
|
|
@@ -2864,7 +2902,7 @@ class Engine_Worker(QtCore.QThread):
|
|
|
2864
2902
|
finished = QtCore.pyqtSignal(dict)
|
|
2865
2903
|
|
|
2866
2904
|
# Message handler signals
|
|
2867
|
-
changed_status = QtCore.pyqtSignal(str)
|
|
2905
|
+
changed_status = QtCore.pyqtSignal(str, int, str)
|
|
2868
2906
|
raised_error = QtCore.pyqtSignal(str)
|
|
2869
2907
|
raised_fatal = QtCore.pyqtSignal(str)
|
|
2870
2908
|
|
|
@@ -2914,7 +2952,7 @@ class Engine_Worker(QtCore.QThread):
|
|
|
2914
2952
|
}
|
|
2915
2953
|
|
|
2916
2954
|
def _messagehandler(self, classname, msgtype, msg):
|
|
2917
|
-
self.changed_status.emit(
|
|
2955
|
+
self.changed_status.emit(classname, msgtype, msg)
|
|
2918
2956
|
|
|
2919
2957
|
def _error(self, msg):
|
|
2920
2958
|
self.raised_error.emit(str(msg))
|
|
@@ -3142,9 +3180,23 @@ def getColor(colorString):
|
|
|
3142
3180
|
|
|
3143
3181
|
|
|
3144
3182
|
def main():
|
|
3183
|
+
debug = False
|
|
3184
|
+
|
|
3185
|
+
print("Trackma-qt v{}".format(utils.VERSION))
|
|
3186
|
+
|
|
3187
|
+
if '-h' in sys.argv:
|
|
3188
|
+
print("Usage: trackma-qt [options]")
|
|
3189
|
+
print()
|
|
3190
|
+
print('Options:')
|
|
3191
|
+
print(' -d Shows debugging information')
|
|
3192
|
+
print(' -h Shows this help')
|
|
3193
|
+
return
|
|
3194
|
+
if '-d' in sys.argv:
|
|
3195
|
+
debug = True
|
|
3196
|
+
|
|
3145
3197
|
app = QApplication(sys.argv)
|
|
3146
3198
|
try:
|
|
3147
|
-
mainwindow = Trackma()
|
|
3199
|
+
mainwindow = Trackma(debug)
|
|
3148
3200
|
sys.exit(app.exec_())
|
|
3149
3201
|
except utils.TrackmaFatal as e:
|
|
3150
3202
|
QMessageBox.critical(None, 'Fatal Error', "{0}".format(e), QMessageBox.Ok)
|
trackma/utils.py
CHANGED
|
@@ -21,7 +21,7 @@ import json
|
|
|
21
21
|
import difflib
|
|
22
22
|
import pickle
|
|
23
23
|
|
|
24
|
-
VERSION = '0.7'
|
|
24
|
+
VERSION = '0.7.3'
|
|
25
25
|
|
|
26
26
|
datadir = os.path.dirname(__file__)
|
|
27
27
|
LOGIN_PASSWD = 1
|
|
@@ -287,6 +287,7 @@ config_defaults = {
|
|
|
287
287
|
'tracker_type': "local",
|
|
288
288
|
'plex_host': "localhost",
|
|
289
289
|
'plex_port': "32400",
|
|
290
|
+
'plex_obey_update_wait_s': False,
|
|
290
291
|
}
|
|
291
292
|
userconfig_defaults = {
|
|
292
293
|
'mediatype': '',
|