Private GIT
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SickRage-1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vlbox
SickRage-1
Commits
98126ee1
Commit
98126ee1
authored
Dec 11, 2015
by
medariox
Browse files
Options
Downloads
Patches
Plain Diff
Fix subs download
parent
8faa81b2
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
sickbeard/subtitles.py
+20
-17
20 additions, 17 deletions
sickbeard/subtitles.py
with
20 additions
and
17 deletions
sickbeard/subtitles.py
+
20
−
17
View file @
98126ee1
...
...
@@ -110,7 +110,7 @@ def enabled_service_list():
def
wanted_languages
(
sql_like
=
None
):
wanted
=
frozenset
(
sickbeard
.
SUBTITLES_LANGUAGES
).
intersection
(
subtitle_code_filter
())
return
(
wanted
,
'
%
'
+
'
,
'
.
join
(
wanted
)
+
'
%
'
)[
bool
(
sql_like
)]
return
(
wanted
,
'
%
'
+
'
,
'
.
join
(
sorted
(
wanted
)
)
+
'
%
'
)[
bool
(
sql_like
)]
def
get_needed_languages
(
subtitles
):
...
...
@@ -427,17 +427,21 @@ class SubtitlesFinder(object):
"""
rules
=
{
'
old
'
:
[
0
,
24
],
'
new
'
:
[
0
,
4
,
8
,
4
,
16
,
24
,
24
]}
if
sickbeard
.
SUBTITLES_MULTI
:
query_languages
=
wanted_languages
(
True
)
else
:
query_languages
=
'
%und%
'
today
=
datetime
.
date
.
today
().
toordinal
()
database
=
db
.
DBConnection
()
sql_results
=
database
.
select
(
'
SELECT s.show_name, e.showid, e.season, e.episode, e.status, e.subtitles,
'
+
'
SELECT s.show_name, e.showid, e.season, e.episode, e.status, e.subtitles,
'
'
e.subtitles_searchcount AS searchcount, e.subtitles_lastsearch AS lastsearch, e.location,
'
'
(? - e.airdate) AS airdate_daydiff
'
+
'
FROM tv_episodes AS e INNER JOIN tv_shows AS s ON (e.showid = s.indexer_id)
'
+
'
WHERE s.subtitles = 1 AND e.subtitles NOT LIKE
(?)
'
+
'
AND (e.subtitles_searchcount <= 2 OR (e.subtitles_searchcount <= 7 AND airdate_daydiff <= 7))
'
+
'
AND e.location !=
""'
,
[
today
,
wanted
_languages
(
True
)
])
'
(? - e.airdate) AS airdate_daydiff
'
'
FROM tv_episodes AS e INNER JOIN tv_shows AS s ON (e.showid = s.indexer_id)
'
'
WHERE s.subtitles = 1 AND e.subtitles NOT LIKE
?
'
'
AND (e.subtitles_searchcount <= 2 OR (e.subtitles_searchcount <= 7 AND airdate_daydiff <= 7))
'
'
AND e.location !=
""'
,
[
today
,
query
_languages
])
if
len
(
sql_results
)
==
0
:
logger
.
log
(
u
'
No subtitles to download
'
,
logger
.
INFO
)
...
...
@@ -445,7 +449,6 @@ class SubtitlesFinder(object):
return
now
=
datetime
.
datetime
.
now
()
for
ep_to_sub
in
sql_results
:
if
not
ek
(
os
.
path
.
isfile
,
ep_to_sub
[
'
location
'
]):
...
...
@@ -453,10 +456,8 @@ class SubtitlesFinder(object):
%
(
ep_to_sub
[
'
show_name
'
],
ep_to_sub
[
'
season
'
],
ep_to_sub
[
'
episode
'
]),
logger
.
DEBUG
)
continue
if
not
needs_subtitles
(
ep_to_sub
[
'
subtitles
'
]):
logger
.
log
(
u
'
Episode already has all needed subtitles, skipping %s S%02dE%02d
'
logger
.
log
(
u
"
%s S%02dE%02d doesn
'
t have all needed subtitles
"
%
(
ep_to_sub
[
'
show_name
'
],
ep_to_sub
[
'
season
'
],
ep_to_sub
[
'
episode
'
]),
logger
.
DEBUG
)
continue
try
:
try
:
...
...
@@ -469,8 +470,8 @@ class SubtitlesFinder(object):
(
ep_to_sub
[
'
airdate_daydiff
'
]
<=
7
and
ep_to_sub
[
'
searchcount
'
]
<
7
and
now
-
lastsearched
>
datetime
.
timedelta
(
hours
=
rules
[
'
new
'
][
ep_to_sub
[
'
searchcount
'
]]))):
logger
.
log
(
u
'
Downloading
subtitles for %s S%02dE%02d
'
%
(
ep_to_sub
[
'
show_name
'
],
ep_to_sub
[
'
season
'
],
ep_to_sub
[
'
episode
'
]),
logger
.
DEBUG
)
logger
.
log
(
u
'
Started
subtitles
search
for %s S%02dE%02d
'
%
(
ep_to_sub
[
'
show_name
'
],
ep_to_sub
[
'
season
'
],
ep_to_sub
[
'
episode
'
]),
logger
.
INFO
)
show_object
=
Show
.
find
(
sickbeard
.
showList
,
int
(
ep_to_sub
[
'
showid
'
]))
if
not
show_object
:
...
...
@@ -489,7 +490,8 @@ class SubtitlesFinder(object):
episode_object
.
download_subtitles
()
except
Exception
as
error
:
logger
.
log
(
u
'
Unable to find subtitles for %s S%02dE%02d. Error: %r
'
%
(
ep_to_sub
[
'
show_name
'
],
ep_to_sub
[
'
season
'
],
ep_to_sub
[
'
episode
'
],
ex
(
error
)),
logger
.
ERROR
)
%
(
ep_to_sub
[
'
show_name
'
],
ep_to_sub
[
'
season
'
],
ep_to_sub
[
'
episode
'
],
ex
(
error
)),
logger
.
ERROR
)
continue
new_subtitles
=
frozenset
(
episode_object
.
subtitles
).
difference
(
existing_subtitles
)
...
...
@@ -499,7 +501,8 @@ class SubtitlesFinder(object):
ep_to_sub
[
"
season
"
],
ep_to_sub
[
"
episode
"
]))
except
Exception
as
error
:
logger
.
log
(
u
'
Error while searching subtitles for %s S%02dE%02d. Error: %r
'
%
(
ep_to_sub
[
'
show_name
'
],
ep_to_sub
[
'
season
'
],
ep_to_sub
[
'
episode
'
],
ex
(
error
)),
logger
.
ERROR
)
%
(
ep_to_sub
[
'
show_name
'
],
ep_to_sub
[
'
season
'
],
ep_to_sub
[
'
episode
'
],
ex
(
error
)),
logger
.
ERROR
)
continue
self
.
amActive
=
False
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment