Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
SiCKRAGE
sickrage
Commits
69cee253
Commit
69cee253
authored
Aug 19, 2018
by
echel0n
Browse files
Misc code cleanup
parent
a2aa3404
Changes
6
Hide whitespace changes
Inline
Side-by-side
changelog.md
View file @
69cee253
# Changelog
-
*
4de0cac - 2018-08-18: Pre-Release v9.3.56.dev28
-
*
c9b0780 - 2018-08-19: Misc code cleanup
-
*
a2aa340 - 2018-08-18: Pre-Release v9.3.56.dev28
-
*
10de224 - 2018-08-18: Pre-Release v9.3.56.dev27
-
*
8efa7cb - 2018-08-18: Fixed broken toggle buttons
-
*
e27a959 - 2018-08-18: Fixed gaierror
'
s for ssdp Fixed WebHandler routing errors
...
...
sickrage/core/queues/show.py
View file @
69cee253
...
...
@@ -44,69 +44,66 @@ class ShowQueue(srQueue):
srQueue
.
__init__
(
self
,
"SHOWQUEUE"
)
@
property
def
loadingShowList
(
self
):
return
self
.
_getLoadingShowList
()
def
_isInQueue
(
self
,
show
,
actions
):
if
not
show
:
return
False
def
loading_show_list
(
self
):
return
self
.
_get_loading_show_list
()
def
_is_in_queue
(
self
,
show
,
actions
):
return
show
.
indexerid
in
[
x
.
show
.
indexerid
if
x
.
show
else
0
for
__
,
__
,
x
in
self
.
queue
if
x
.
action_id
in
actions
]
x
.
action_id
in
actions
]
if
show
else
False
def
_is
B
eing
(
self
,
show
,
actions
):
def
_is
_b
eing
(
self
,
show
,
actions
):
return
self
.
currentItem
is
not
None
and
show
==
self
.
currentItem
.
show
and
self
.
currentItem
.
action_id
in
actions
def
is
InU
pdate
Q
ueue
(
self
,
show
):
return
self
.
_is
InQ
ueue
(
show
,
(
ShowQueueActions
.
UPDATE
,
ShowQueueActions
.
FORCEUPDATE
))
def
is
_in_u
pdate
_q
ueue
(
self
,
show
):
return
self
.
_is
_in_q
ueue
(
show
,
(
ShowQueueActions
.
UPDATE
,
ShowQueueActions
.
FORCEUPDATE
))
def
is
InR
efresh
Q
ueue
(
self
,
show
):
return
self
.
_is
InQ
ueue
(
show
,
(
ShowQueueActions
.
REFRESH
,))
def
is
_in_r
efresh
_q
ueue
(
self
,
show
):
return
self
.
_is
_in_q
ueue
(
show
,
(
ShowQueueActions
.
REFRESH
,))
def
is
InR
ename
Q
ueue
(
self
,
show
):
return
self
.
_is
InQ
ueue
(
show
,
(
ShowQueueActions
.
RENAME
,))
def
is
_in_r
ename
_q
ueue
(
self
,
show
):
return
self
.
_is
_in_q
ueue
(
show
,
(
ShowQueueActions
.
RENAME
,))
def
is
InS
ubtitle
Q
ueue
(
self
,
show
):
return
self
.
_is
InQ
ueue
(
show
,
(
ShowQueueActions
.
SUBTITLE
,))
def
is
_in_s
ubtitle
_q
ueue
(
self
,
show
):
return
self
.
_is
_in_q
ueue
(
show
,
(
ShowQueueActions
.
SUBTITLE
,))
def
is
B
eing
R
emoved
(
self
,
show
):
return
self
.
_is
B
eing
(
show
,
(
ShowQueueActions
.
REMOVE
,))
def
is
_b
eing
_r
emoved
(
self
,
show
):
return
self
.
_is
_b
eing
(
show
,
(
ShowQueueActions
.
REMOVE
,))
def
is
B
eing
A
dded
(
self
,
show
):
return
self
.
_is
B
eing
(
show
,
(
ShowQueueActions
.
ADD
,))
def
is
_b
eing
_a
dded
(
self
,
show
):
return
self
.
_is
_b
eing
(
show
,
(
ShowQueueActions
.
ADD
,))
def
is
B
eing
U
pdated
(
self
,
show
):
return
self
.
_is
B
eing
(
show
,
(
ShowQueueActions
.
UPDATE
,
ShowQueueActions
.
FORCEUPDATE
))
def
is
_b
eing
_u
pdated
(
self
,
show
):
return
self
.
_is
_b
eing
(
show
,
(
ShowQueueActions
.
UPDATE
,
ShowQueueActions
.
FORCEUPDATE
))
def
is
B
eing
R
efreshed
(
self
,
show
):
return
self
.
_is
B
eing
(
show
,
(
ShowQueueActions
.
REFRESH
,))
def
is
_b
eing
_r
efreshed
(
self
,
show
):
return
self
.
_is
_b
eing
(
show
,
(
ShowQueueActions
.
REFRESH
,))
def
is
B
eing
R
enamed
(
self
,
show
):
return
self
.
_is
B
eing
(
show
,
(
ShowQueueActions
.
RENAME
,))
def
is
_b
eing
_r
enamed
(
self
,
show
):
return
self
.
_is
_b
eing
(
show
,
(
ShowQueueActions
.
RENAME
,))
def
is
B
eing
S
ubtitled
(
self
,
show
):
return
self
.
_is
B
eing
(
show
,
(
ShowQueueActions
.
SUBTITLE
,))
def
is
_b
eing
_s
ubtitled
(
self
,
show
):
return
self
.
_is
_b
eing
(
show
,
(
ShowQueueActions
.
SUBTITLE
,))
def
_get
L
oading
S
how
L
ist
(
self
):
return
[
x
for
__
,
__
,
x
in
self
.
queue
+
[(
None
,
None
,
self
.
currentItem
)]
if
x
and
x
.
is
L
oading
]
def
_get
_l
oading
_s
how
_l
ist
(
self
):
return
[
x
for
__
,
__
,
x
in
self
.
queue
+
[(
None
,
None
,
self
.
currentItem
)]
if
x
and
x
.
is
_l
oading
]
def
updateShow
(
self
,
show
,
force
=
False
):
if
self
.
is
B
eing
A
dded
(
show
):
if
self
.
is
_b
eing
_a
dded
(
show
):
raise
CantUpdateShowException
(
"{} is still being added, please wait until it is finished before trying to "
"update."
.
format
(
show
.
name
))
if
self
.
is
B
eing
U
pdated
(
show
):
if
self
.
is
_b
eing
_u
pdated
(
show
):
raise
CantUpdateShowException
(
"{} is already being updated, can't update again until "
"it's done."
.
format
(
show
.
name
))
if
self
.
is
InU
pdate
Q
ueue
(
show
):
if
self
.
is
_in_u
pdate
_q
ueue
(
show
):
raise
CantUpdateShowException
(
"{} is in the process of being updated, can't update again until "
"it's done."
.
format
(
show
.
name
))
return
self
.
put
(
QueueItemForceUpdate
(
show
))
if
force
else
self
.
put
(
QueueItemUpdate
(
show
))
def
refreshShow
(
self
,
show
,
force
=
False
):
if
(
self
.
is
B
eing
R
efreshed
(
show
)
or
self
.
is
InR
efresh
Q
ueue
(
show
))
and
not
force
:
if
(
self
.
is
_b
eing
_r
efreshed
(
show
)
or
self
.
is
_in_r
efresh
_q
ueue
(
show
))
and
not
force
:
raise
CantRefreshShowException
(
"This show is already being refreshed or queued to be refreshed, skipping "
"this request."
)
...
...
@@ -153,7 +150,7 @@ class ShowQueue(srQueue):
raise
CantRemoveShowException
(
'Failed removing show: Show does not exist'
)
elif
not
hasattr
(
show
,
'indexerid'
):
raise
CantRemoveShowException
(
'Failed removing show: Show does not have an indexer id'
)
elif
self
.
_is
InQ
ueue
(
show
,
(
ShowQueueActions
.
REMOVE
,)):
elif
self
.
_is
_in_q
ueue
(
show
,
(
ShowQueueActions
.
REMOVE
,)):
raise
CantRemoveShowException
(
"{} is already queued to be removed"
.
format
(
show
))
# remove other queued actions for this show.
...
...
@@ -202,12 +199,11 @@ class ShowQueueItem(srQueueItem):
def
__init__
(
self
,
show
,
action_id
):
super
(
ShowQueueItem
,
self
).
__init__
(
ShowQueueActions
.
names
[
action_id
],
action_id
)
self
.
show
=
show
self
.
startTime
=
time
.
time
()
def
finish
(
self
):
self
.
show
.
flushEpisodes
()
def
is
InQ
ueue
(
self
):
def
is
_in_q
ueue
(
self
):
return
self
in
sickrage
.
app
.
show_queue
.
queue
+
[
sickrage
.
app
.
show_queue
.
currentItem
]
@
property
...
...
@@ -215,7 +211,7 @@ class ShowQueueItem(srQueueItem):
return
str
(
self
.
show
.
indexerid
)
@
property
def
is
L
oading
(
self
):
def
is
_l
oading
(
self
):
return
False
...
...
@@ -249,12 +245,10 @@ class QueueItemAdd(ShowQueueItem):
Returns the show name if there is a show object created, if not returns
the dir that the show is being added to.
"""
if
self
.
show
is
None
:
return
os
.
path
.
basename
(
self
.
showDir
)
return
self
.
show
.
name
return
self
.
show
.
name
if
self
.
show
else
os
.
path
.
basename
(
self
.
showDir
)
@
property
def
is
L
oading
(
self
):
def
is
_l
oading
(
self
):
"""
Returns True if we've gotten far enough to have a show object, or False
if we still only know the folder name.
...
...
@@ -263,6 +257,8 @@ class QueueItemAdd(ShowQueueItem):
return
True
def
run
(
self
):
start_time
=
time
.
time
()
sickrage
.
app
.
log
.
info
(
"Started adding show {} from show dir: {}"
.
format
(
self
.
show_name
,
self
.
showDir
))
index_name
=
IndexerApi
(
self
.
indexer
).
name
...
...
@@ -284,7 +280,7 @@ class QueueItemAdd(ShowQueueItem):
s
=
None
if
not
s
:
return
self
.
_finish
E
arly
()
return
self
.
_finish
_e
arly
()
# this usually only happens if they have an NFO in their show dir which gave us a Indexer ID that has no proper english version of the show
if
not
getattr
(
s
,
'seriesname'
):
...
...
@@ -295,7 +291,7 @@ class QueueItemAdd(ShowQueueItem):
_
(
"Show in {} has no name on {}, probably the wrong language. Delete .nfo "
"and add manually in the correct language"
).
format
(
self
.
showDir
,
index_name
))
return
self
.
_finish
E
arly
()
return
self
.
_finish
_e
arly
()
# if the show has no episodes/seasons
if
not
len
(
s
):
...
...
@@ -306,7 +302,7 @@ class QueueItemAdd(ShowQueueItem):
IndexerApi
(
self
.
indexer
).
name
)
+
_
(
" but contains no season/episode data."
))
return
self
.
_finish
E
arly
()
return
self
.
_finish
_e
arly
()
except
Exception
as
e
:
sickrage
.
app
.
log
.
error
(
"{}: Error while loading information from indexer {}. Error: {}"
.
format
(
self
.
indexer_id
,
index_name
,
e
))
...
...
@@ -331,7 +327,7 @@ class QueueItemAdd(ShowQueueItem):
srTraktAPI
()[
"sync/watchlist"
].
remove
(
data
)
return
self
.
_finish
E
arly
()
return
self
.
_finish
_e
arly
()
try
:
self
.
show
=
TVShow
(
self
.
indexer
,
self
.
indexer_id
,
self
.
lang
)
...
...
@@ -381,18 +377,18 @@ class QueueItemAdd(ShowQueueItem):
else
:
sickrage
.
app
.
alerts
.
error
(
_
(
"Unable to add show due to an error with "
)
+
IndexerApi
(
self
.
indexer
).
name
+
""
)
return
self
.
_finish
E
arly
()
return
self
.
_finish
_e
arly
()
except
MultipleShowObjectsException
:
sickrage
.
app
.
log
.
warning
(
"The show in "
+
self
.
showDir
+
" is already in your show list, skipping"
)
sickrage
.
app
.
alerts
.
error
(
_
(
'Show skipped'
),
_
(
"The show in "
)
+
self
.
showDir
+
_
(
" is already in your show list"
))
return
self
.
_finish
E
arly
()
return
self
.
_finish
_e
arly
()
except
Exception
as
e
:
sickrage
.
app
.
log
.
error
(
"Error trying to add show: {}"
.
format
(
e
))
sickrage
.
app
.
log
.
debug
(
traceback
.
format_exc
())
raise
self
.
_finish
E
arly
()
raise
self
.
_finish
_e
arly
()
try
:
sickrage
.
app
.
log
.
debug
(
"Attempting to retrieve show info from IMDb"
)
...
...
@@ -405,7 +401,7 @@ class QueueItemAdd(ShowQueueItem):
except
Exception
as
e
:
sickrage
.
app
.
log
.
error
(
"Error saving the show to the database: {}"
.
format
(
e
))
sickrage
.
app
.
log
.
debug
(
traceback
.
format_exc
())
raise
self
.
_finish
E
arly
()
raise
self
.
_finish
_e
arly
()
# add it to the show list
if
not
findCertainShow
(
self
.
indexer_id
):
...
...
@@ -464,10 +460,10 @@ class QueueItemAdd(ShowQueueItem):
sickrage
.
app
.
log
.
info
(
"Finished adding show {} in {}s from show dir: {}"
.
format
(
self
.
show_name
,
round
(
time
.
time
()
-
self
.
start
T
ime
,
2
),
round
(
time
.
time
()
-
start
_t
ime
,
2
),
self
.
showDir
))
def
_finish
E
arly
(
self
):
def
_finish
_e
arly
(
self
):
if
self
.
show
:
sickrage
.
app
.
show_queue
.
removeShow
(
self
.
show
)
...
...
@@ -479,6 +475,8 @@ class QueueItemRefresh(ShowQueueItem):
self
.
force
=
force
def
run
(
self
):
start_time
=
time
.
time
()
sickrage
.
app
.
log
.
info
(
"Performing refresh for show: {}"
.
format
(
self
.
show
.
name
))
self
.
show
.
refreshDir
()
...
...
@@ -494,7 +492,7 @@ class QueueItemRefresh(ShowQueueItem):
self
.
finish
()
sickrage
.
app
.
log
.
info
(
"Finished refresh in {}s for show: {}"
.
format
(
round
(
time
.
time
()
-
self
.
start
T
ime
,
2
),
self
.
show
.
name
))
"Finished refresh in {}s for show: {}"
.
format
(
round
(
time
.
time
()
-
start
_t
ime
,
2
),
self
.
show
.
name
))
class
QueueItemRename
(
ShowQueueItem
):
...
...
@@ -556,6 +554,8 @@ class QueueItemUpdate(ShowQueueItem):
self
.
force
=
False
def
run
(
self
):
start_time
=
time
.
time
()
sickrage
.
app
.
log
.
info
(
"Performing updates for show: {}"
.
format
(
self
.
show
.
name
))
try
:
...
...
@@ -614,7 +614,7 @@ class QueueItemUpdate(ShowQueueItem):
sickrage
.
app
.
quicksearch_cache
.
update_show
(
self
.
show
.
indexerid
)
sickrage
.
app
.
log
.
info
(
"Finished updates in {}s for show: {}"
.
format
(
round
(
time
.
time
()
-
self
.
start
T
ime
,
2
),
self
.
show
.
name
))
"Finished updates in {}s for show: {}"
.
format
(
round
(
time
.
time
()
-
start
_t
ime
,
2
),
self
.
show
.
name
))
# refresh show
sickrage
.
app
.
show_queue
.
refreshShow
(
self
.
show
,
self
.
force
)
...
...
@@ -635,7 +635,7 @@ class QueueItemRemove(ShowQueueItem):
self
.
full
=
full
@
property
def
is
L
oading
(
self
):
def
is
_l
oading
(
self
):
"""
Returns false cause we are removing the show.
"""
...
...
sickrage/core/ui.py
View file @
69cee253
...
...
@@ -154,10 +154,10 @@ class QueueProgressIndicator():
return
len
(
self
.
queueItemList
)
def
numFinished
(
self
):
return
len
([
x
for
x
in
self
.
queueItemList
if
not
x
.
is
InQ
ueue
()])
return
len
([
x
for
x
in
self
.
queueItemList
if
not
x
.
is
_in_q
ueue
()])
def
numRemaining
(
self
):
return
len
([
x
for
x
in
self
.
queueItemList
if
x
.
is
InQ
ueue
()])
return
len
([
x
for
x
in
self
.
queueItemList
if
x
.
is
_in_q
ueue
()])
def
nextName
(
self
):
for
curItem
in
[
sickrage
.
app
.
show_queue
.
currentItem
]
+
sickrage
.
app
.
show_queue
.
queue
:
...
...
sickrage/core/webserver/views.py
View file @
69cee253
...
...
@@ -1102,29 +1102,29 @@ class Home(WebHandler):
show_message
=
''
if
sickrage
.
app
.
show_queue
.
is
B
eing
A
dded
(
showObj
):
if
sickrage
.
app
.
show_queue
.
is
_b
eing
_a
dded
(
showObj
):
show_message
=
_
(
'This show is in the process of being downloaded - the info below is incomplete.'
)
elif
sickrage
.
app
.
show_queue
.
is
B
eing
U
pdated
(
showObj
):
elif
sickrage
.
app
.
show_queue
.
is
_b
eing
_u
pdated
(
showObj
):
show_message
=
_
(
'The information on this page is in the process of being updated.'
)
elif
sickrage
.
app
.
show_queue
.
is
B
eing
R
efreshed
(
showObj
):
elif
sickrage
.
app
.
show_queue
.
is
_b
eing
_r
efreshed
(
showObj
):
show_message
=
_
(
'The episodes below are currently being refreshed from disk'
)
elif
sickrage
.
app
.
show_queue
.
is
B
eing
S
ubtitled
(
showObj
):
elif
sickrage
.
app
.
show_queue
.
is
_b
eing
_s
ubtitled
(
showObj
):
show_message
=
_
(
'Currently downloading subtitles for this show'
)
elif
sickrage
.
app
.
show_queue
.
is
InR
efresh
Q
ueue
(
showObj
):
elif
sickrage
.
app
.
show_queue
.
is
_in_r
efresh
_q
ueue
(
showObj
):
show_message
=
_
(
'This show is queued to be refreshed.'
)
elif
sickrage
.
app
.
show_queue
.
is
InU
pdate
Q
ueue
(
showObj
):
elif
sickrage
.
app
.
show_queue
.
is
_in_u
pdate
_q
ueue
(
showObj
):
show_message
=
_
(
'This show is queued and awaiting an update.'
)
elif
sickrage
.
app
.
show_queue
.
is
InS
ubtitle
Q
ueue
(
showObj
):
elif
sickrage
.
app
.
show_queue
.
is
_in_s
ubtitle
_q
ueue
(
showObj
):
show_message
=
_
(
'This show is queued and awaiting subtitles download.'
)
if
not
sickrage
.
app
.
show_queue
.
is
B
eing
A
dded
(
showObj
):
if
not
sickrage
.
app
.
show_queue
.
is
B
eing
U
pdated
(
showObj
):
if
not
sickrage
.
app
.
show_queue
.
is
_b
eing
_a
dded
(
showObj
):
if
not
sickrage
.
app
.
show_queue
.
is
_b
eing
_u
pdated
(
showObj
):
if
showObj
.
paused
:
submenu
.
append
({
'title'
:
_
(
'Resume'
),
'path'
:
'/home/togglePause?show=%d'
%
showObj
.
indexerid
,
'icon'
:
'fas fa-play'
})
...
...
@@ -1148,7 +1148,7 @@ class Home(WebHandler):
submenu
.
append
({
'title'
:
_
(
'Preview Rename'
),
'path'
:
'/home/testRename?show=%d'
%
showObj
.
indexerid
,
'icon'
:
'fas fa-tag'
})
if
sickrage
.
app
.
config
.
use_subtitles
and
not
sickrage
.
app
.
show_queue
.
is
B
eing
S
ubtitled
(
if
sickrage
.
app
.
config
.
use_subtitles
and
not
sickrage
.
app
.
show_queue
.
is
_b
eing
_s
ubtitled
(
showObj
)
and
showObj
.
subtitles
:
submenu
.
append
(
{
'title'
:
_
(
'Download Subtitles'
),
'path'
:
'/home/subtitleShow?show=%d'
%
showObj
.
indexerid
,
...
...
sickrage/core/webserver/views/home/index.mako
View file @
69cee253
...
...
@@ -111,7 +111,7 @@
<div id="${('container', 'container-anime')[curListType == 'Anime' and sickrage.app.config.home_layout == 'poster']}"
class="show-grid clearfix mx-auto d-none">
<div class="posterview">
% for curLoadingShow in sickrage.app.show_queue.loading
S
how
L
ist:
% for curLoadingShow in sickrage.app.show_queue.loading
_s
how
_l
ist:
% if not curLoadingShow.show:
<div class="show-container" data-name="0" data-date="010101" data-network="0"
data-progress="101">
...
...
@@ -296,9 +296,9 @@
</tr>
</thead>
% if sickrage.app.show_queue.loading
S
how
L
ist:
% if sickrage.app.show_queue.loading
_s
how
_l
ist:
<tbody>
% for curLoadingShow in sickrage.app.show_queue.loading
S
how
L
ist:
% for curLoadingShow in sickrage.app.show_queue.loading
_s
how
_l
ist:
% if not curLoadingShow.show or curLoadingShow.show not in sickrage.app.showlist:
<tr>
<td class="table-fit">(${_('loading')})</td>
...
...
sickrage/core/webserver/views/manage/mass_update.mako
View file @
69cee253
...
...
@@ -86,7 +86,7 @@
<td class="table-fit">
<input type="checkbox" class="showCheck"
id="${curShow.indexerid}"
name="${curShow.indexerid}" ${('disabled', '')[bool(not any([sickrage.app.show_queue.is
B
eing
R
enamed(curShow), sickrage.app.show_queue.is
InR
ename
Q
ueue(curShow), sickrage.app.show_queue.is
InR
efresh
Q
ueue(curShow), sickrage.app.show_queue.is
B
eing
U
pdated(curShow),sickrage.app.show_queue.is
InU
pdate
Q
ueue(curShow), sickrage.app.show_queue.is
B
eing
R
efreshed(curShow), sickrage.app.show_queue.is
InR
efresh
Q
ueue(curShow), sickrage.app.show_queue.is
B
eing
R
enamed(curShow), sickrage.app.show_queue.is
InR
ename
Q
ueue(curShow), sickrage.app.show_queue.is
B
eing
S
ubtitled(curShow), sickrage.app.show_queue.is
InS
ubtitle
Q
ueue(curShow)]))]}/>
name="${curShow.indexerid}" ${('disabled', '')[bool(not any([sickrage.app.show_queue.is
_b
eing
_r
enamed(curShow), sickrage.app.show_queue.is
_in_r
ename
_q
ueue(curShow), sickrage.app.show_queue.is
_in_r
efresh
_q
ueue(curShow), sickrage.app.show_queue.is
_b
eing
_u
pdated(curShow),sickrage.app.show_queue.is
_in_u
pdate
_q
ueue(curShow), sickrage.app.show_queue.is
_b
eing
_r
efreshed(curShow), sickrage.app.show_queue.is
_in_r
efresh
_q
ueue(curShow), sickrage.app.show_queue.is
_b
eing
_r
enamed(curShow), sickrage.app.show_queue.is
_in_r
ename
_q
ueue(curShow), sickrage.app.show_queue.is
_b
eing
_s
ubtitled(curShow), sickrage.app.show_queue.is
_in_s
ubtitle
_q
ueue(curShow)]))]}/>
</td>
<td class="tvShow">
<a href="${srWebRoot}/home/displayShow?show=${curShow.indexerid}">${curShow.name}</a>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment