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
9c373c2d
Commit
9c373c2d
authored
Jul 16, 2015
by
Dustyn Gibson
Browse files
Options
Downloads
Patches
Plain Diff
Move and improve subtitles codes check
parent
8c273728
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
SickBeard.py
+0
-26
0 additions, 26 deletions
SickBeard.py
sickbeard/databases/mainDB.py
+32
-0
32 additions, 0 deletions
sickbeard/databases/mainDB.py
with
32 additions
and
26 deletions
SickBeard.py
+
0
−
26
View file @
9c373c2d
...
@@ -474,32 +474,6 @@ class SickRage(object):
...
@@ -474,32 +474,6 @@ class SickRage(object):
logger
.
ERROR
)
logger
.
ERROR
)
logger
.
log
(
traceback
.
format_exc
(),
logger
.
DEBUG
)
logger
.
log
(
traceback
.
format_exc
(),
logger
.
DEBUG
)
self
.
fix_subtitles_codes
()
def
fix_subtitles_codes
(
self
):
myDB
=
db
.
DBConnection
()
sqlResults
=
myDB
.
select
(
"
SELECT showid, subtitles_lastsearch, season, episode FROM tv_episodes
"
+
"
WHERE subtitles !=
''
AND subtitles_lastsearch < ?;
"
,
[
datetime
.
datetime
(
2015
,
7
,
15
,
17
,
20
,
44
,
326380
).
strftime
(
"
%Y-%m-%d %H:%M:%S
"
)])
if
not
sqlResults
:
return
logger
.
log
(
"
Fixing old subtitle codes
"
)
for
sqlResult
in
sqlResults
:
showObj
=
sickbeard
.
helpers
.
findCertainShow
(
sickbeard
.
showList
,
int
(
sqlResult
[
'
showid
'
]))
if
not
showObj
:
continue
epObj
=
showObj
.
getEpisode
(
int
(
sqlResult
[
"
season
"
]),
int
(
sqlResult
[
"
episode
"
]))
if
isinstance
(
epObj
,
str
):
continue
epObj
.
refreshSubtitles
()
epObj
.
subtitles_lastsearch
=
datetime
.
datetime
.
now
().
strftime
(
"
%Y-%m-%d %H:%M:%S
"
)
epObj
.
saveToDB
()
def
restoreDB
(
self
,
srcDir
,
dstDir
):
def
restoreDB
(
self
,
srcDir
,
dstDir
):
try
:
try
:
...
...
This diff is collapsed.
Click to expand it.
sickbeard/databases/mainDB.py
+
32
−
0
View file @
9c373c2d
...
@@ -26,6 +26,8 @@ from sickbeard import db, common, helpers, logger
...
@@ -26,6 +26,8 @@ from sickbeard import db, common, helpers, logger
from
sickbeard
import
encodingKludge
as
ek
from
sickbeard
import
encodingKludge
as
ek
from
sickbeard.name_parser.parser
import
NameParser
,
InvalidNameException
,
InvalidShowException
from
sickbeard.name_parser.parser
import
NameParser
,
InvalidNameException
,
InvalidShowException
from
babelfish
import
Language
MIN_DB_VERSION
=
9
# oldest db version we support migrating from
MIN_DB_VERSION
=
9
# oldest db version we support migrating from
MAX_DB_VERSION
=
42
MAX_DB_VERSION
=
42
...
@@ -39,6 +41,7 @@ class MainSanityCheck(db.DBSanityCheck):
...
@@ -39,6 +41,7 @@ class MainSanityCheck(db.DBSanityCheck):
self
.
fix_tvrage_show_statues
()
self
.
fix_tvrage_show_statues
()
self
.
fix_episode_statuses
()
self
.
fix_episode_statuses
()
self
.
fix_invalid_airdates
()
self
.
fix_invalid_airdates
()
self
.
fix_subtitles_codes
()
def
fix_duplicate_shows
(
self
,
column
=
'
indexer_id
'
):
def
fix_duplicate_shows
(
self
,
column
=
'
indexer_id
'
):
...
@@ -192,6 +195,35 @@ class MainSanityCheck(db.DBSanityCheck):
...
@@ -192,6 +195,35 @@ class MainSanityCheck(db.DBSanityCheck):
else
:
else
:
logger
.
log
(
u
"
No bad episode airdates, check passed
"
,
logger
.
DEBUG
)
logger
.
log
(
u
"
No bad episode airdates, check passed
"
,
logger
.
DEBUG
)
def
fix_subtitles_codes
(
self
):
sqlResults
=
self
.
connection
.
select
(
"
SELECT subtitles, episode_id FROM tv_episodes WHERE subtitles !=
''
AND subtitles_lastsearch < ?;
"
,
[
datetime
.
datetime
(
2015
,
7
,
15
,
17
,
20
,
44
,
326380
).
strftime
(
"
%Y-%m-%d %H:%M:%S
"
)])
if
not
sqlResults
:
return
for
sqlResult
in
sqlResults
:
langs
=
[]
logger
.
log
(
"
Checking subtitle codes for episode_id: %s, codes: %s
"
%
(
sqlResult
[
'
episode_id
'
],
sqlResult
[
'
subtitles
'
]),
logger
.
DEBUG
)
for
subcode
in
sqlResult
[
'
subtitles
'
].
split
(
'
,
'
):
try
:
Language
.
fromopensubtitles
(
subcode
)
except
Exception
:
logger
.
log
(
"
Fixing subtitle codes for episode_id: %s, invalid code: %s
"
%
(
sqlResult
[
'
episode_id
'
],
subcode
),
logger
.
DEBUG
)
continue
langs
.
append
(
subcode
)
self
.
connection
.
action
(
"
UPDATE tv_episodes SET subtitles = ?, subtitles_lastsearch = ? WHERE episode_id = ?;
"
,
[
'
,
'
.
join
(
langs
),
datetime
.
datetime
.
now
().
strftime
(
"
%Y-%m-%d %H:%M:%S
"
),
sqlResult
[
'
episode_id
'
]])
def
backupDatabase
(
version
):
def
backupDatabase
(
version
):
logger
.
log
(
u
"
Backing up database before upgrade
"
)
logger
.
log
(
u
"
Backing up database before upgrade
"
)
if
not
helpers
.
backupVersionedFile
(
db
.
dbFilename
(),
version
):
if
not
helpers
.
backupVersionedFile
(
db
.
dbFilename
(),
version
):
...
...
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