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
c6d2240a
Commit
c6d2240a
authored
Jul 12, 2015
by
Dustyn Gibson
Browse files
Options
Downloads
Plain Diff
Merge branch 'scene-exceptions-memory-hog' into develop
parents
1eaebaab
5ee5c003
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
sickbeard/databases/cache_db.py
+7
-8
7 additions, 8 deletions
sickbeard/databases/cache_db.py
sickbeard/network_timezones.py
+6
-6
6 additions, 6 deletions
sickbeard/network_timezones.py
sickbeard/scene_exceptions.py
+11
-19
11 additions, 19 deletions
sickbeard/scene_exceptions.py
with
24 additions
and
33 deletions
sickbeard/databases/cache_db.py
+
7
−
8
View file @
c6d2240a
...
@@ -24,15 +24,14 @@ class InitialSchema(db.SchemaUpgrade):
...
@@ -24,15 +24,14 @@ class InitialSchema(db.SchemaUpgrade):
return
self
.
hasTable
(
"
db_version
"
)
return
self
.
hasTable
(
"
db_version
"
)
def
execute
(
self
):
def
execute
(
self
):
queries
=
[
queries
=
[
(
"
CREATE TABLE db_version (db_version INTEGER);
"
,),
(
"
CREATE TABLE lastUpdate (provider TEXT, time NUMERIC);
"
,),
(
"
CREATE TABLE lastUpdate (provider TEXT, time NUMERIC);
"
,),
(
"
CREATE TABLE lastSearch (provider TEXT, time NUMERIC);
"
,),
(
"
CREATE TABLE lastSearch (provider TEXT, time NUMERIC);
"
,),
(
"
CREATE TABLE scene_exceptions (exception_id INTEGER PRIMARY KEY, indexer_id INTEGER KEY, show_name TEXT, season NUMERIC DEFAULT -1, custom NUMERIC DEFAULT 0);
"
,),
(
"
CREATE TABLE scene_exceptions (exception_id INTEGER PRIMARY KEY, indexer_id INTEGER KEY, show_name TEXT, season NUMERIC DEFAULT -1, custom NUMERIC DEFAULT 0);
"
,),
(
"
CREATE TABLE scene_names (indexer_id INTEGER, name TEXT);
"
,),
(
"
CREATE TABLE scene_names (indexer_id INTEGER, name TEXT);
"
,),
(
"
CREATE TABLE network_timezones (network_name TEXT PRIMARY KEY, timezone TEXT);
"
,),
(
"
CREATE TABLE network_timezones (network_name TEXT PRIMARY KEY, timezone TEXT);
"
,),
(
"
CREATE TABLE scene_exceptions_refresh (list TEXT PRIMARY KEY, last_refreshed INTEGER);
"
,),
(
"
CREATE TABLE scene_exceptions_refresh (list TEXT PRIMARY KEY, last_refreshed INTEGER);
"
,),
(
"
CREATE TABLE db_version (db_version INTEGER);
"
,),
(
"
INSERT INTO db_version(db_version) VALUES (1);
"
,),
(
"
INSERT INTO db_version(db_version) VALUES (1);
"
,),
]
]
for
query
in
queries
:
for
query
in
queries
:
...
@@ -48,14 +47,14 @@ class AddSceneExceptions(InitialSchema):
...
@@ -48,14 +47,14 @@ class AddSceneExceptions(InitialSchema):
def
execute
(
self
):
def
execute
(
self
):
self
.
connection
.
action
(
self
.
connection
.
action
(
"
CREATE TABLE scene_exceptions (exception_id INTEGER PRIMARY KEY, indexer_id INTEGER KEY, show_name TEXT)
"
)
"
CREATE TABLE scene_exceptions (exception_id INTEGER PRIMARY KEY, indexer_id INTEGER KEY, show_name TEXT)
;
"
)
class
AddSceneNameCache
(
AddSceneExceptions
):
class
AddSceneNameCache
(
AddSceneExceptions
):
def
test
(
self
):
def
test
(
self
):
return
self
.
hasTable
(
"
scene_names
"
)
return
self
.
hasTable
(
"
scene_names
"
)
def
execute
(
self
):
def
execute
(
self
):
self
.
connection
.
action
(
"
CREATE TABLE scene_names (indexer_id INTEGER, name TEXT)
"
)
self
.
connection
.
action
(
"
CREATE TABLE scene_names (indexer_id INTEGER, name TEXT)
;
"
)
class
AddNetworkTimezones
(
AddSceneNameCache
):
class
AddNetworkTimezones
(
AddSceneNameCache
):
...
@@ -63,16 +62,16 @@ class AddNetworkTimezones(AddSceneNameCache):
...
@@ -63,16 +62,16 @@ class AddNetworkTimezones(AddSceneNameCache):
return
self
.
hasTable
(
"
network_timezones
"
)
return
self
.
hasTable
(
"
network_timezones
"
)
def
execute
(
self
):
def
execute
(
self
):
self
.
connection
.
action
(
"
CREATE TABLE network_timezones (network_name TEXT PRIMARY KEY, timezone TEXT)
"
)
self
.
connection
.
action
(
"
CREATE TABLE network_timezones (network_name TEXT PRIMARY KEY, timezone TEXT)
;
"
)
class
AddLastSearch
(
AddNetworkTimezones
):
class
AddLastSearch
(
AddNetworkTimezones
):
def
test
(
self
):
def
test
(
self
):
return
self
.
hasTable
(
"
lastSearch
"
)
return
self
.
hasTable
(
"
lastSearch
"
)
def
execute
(
self
):
def
execute
(
self
):
self
.
connection
.
action
(
"
CREATE TABLE lastSearch (provider TEXT, time NUMERIC)
"
)
self
.
connection
.
action
(
"
CREATE TABLE lastSearch (provider TEXT, time NUMERIC)
;
"
)
class
AddSceneExceptionsSeasons
(
Add
SceneNameCa
ch
e
):
class
AddSceneExceptionsSeasons
(
Add
LastSear
ch
):
def
test
(
self
):
def
test
(
self
):
return
self
.
hasColumn
(
"
scene_exceptions
"
,
"
season
"
)
return
self
.
hasColumn
(
"
scene_exceptions
"
,
"
season
"
)
...
@@ -92,4 +91,4 @@ class AddSceneExceptionsRefresh(AddSceneExceptionsCustom):
...
@@ -92,4 +91,4 @@ class AddSceneExceptionsRefresh(AddSceneExceptionsCustom):
def
execute
(
self
):
def
execute
(
self
):
self
.
connection
.
action
(
self
.
connection
.
action
(
"
CREATE TABLE scene_exceptions_refresh (list TEXT PRIMARY KEY, last_refreshed INTEGER)
"
)
"
CREATE TABLE scene_exceptions_refresh (list TEXT PRIMARY KEY, last_refreshed INTEGER)
;
"
)
This diff is collapsed.
Click to expand it.
sickbeard/network_timezones.py
+
6
−
6
View file @
c6d2240a
...
@@ -171,22 +171,22 @@ def update_network_dict():
...
@@ -171,22 +171,22 @@ def update_network_dict():
my_db
=
db
.
DBConnection
(
'
cache.db
'
)
my_db
=
db
.
DBConnection
(
'
cache.db
'
)
network_list
=
dict
(
my_db
.
select
(
'
SELECT * FROM network_timezones
'
))
network_list
=
dict
(
my_db
.
select
(
'
SELECT * FROM network_timezones
;
'
))
queries
=
[]
queries
=
[]
for
network
,
timezone
in
d
.
iteritems
():
for
network
,
timezone
in
d
.
iteritems
():
existing
=
network_list
.
has_key
(
network
)
existing
=
network_list
.
has_key
(
network
)
if
not
existing
:
if
not
existing
:
queries
.
append
([
'
INSERT OR IGNORE INTO network_timezones VALUES (?,?)
'
,
[
network
,
timezone
]])
queries
.
append
([
'
INSERT OR IGNORE INTO network_timezones VALUES (?,?)
;
'
,
[
network
,
timezone
]])
elif
network_list
[
network
]
is
not
timezone
:
elif
network_list
[
network
]
is
not
timezone
:
queries
.
append
([
'
UPDATE OR IGNORE network_timezones SET timezone = ? WHERE network_name = ?
'
,
[
timezone
,
network
]])
queries
.
append
([
'
UPDATE OR IGNORE network_timezones SET timezone = ? WHERE network_name = ?
;
'
,
[
timezone
,
network
]])
if
existing
:
if
existing
:
del
network_list
[
network
]
del
network_list
[
network
]
if
network_list
:
if
network_list
:
purged
=
list
(
x
for
x
in
network_list
)
purged
=
list
(
x
for
x
in
network_list
)
queries
.
append
([
'
DELETE FROM network_timezones WHERE network_name IN (%s)
'
%
'
,
'
.
join
([
'
?
'
]
*
len
(
purged
)),
purged
])
queries
.
append
([
'
DELETE FROM network_timezones WHERE network_name IN (%s)
;
'
%
'
,
'
.
join
([
'
?
'
]
*
len
(
purged
)),
purged
])
if
queries
:
if
queries
:
my_db
.
mass_action
(
queries
)
my_db
.
mass_action
(
queries
)
...
@@ -197,10 +197,10 @@ def update_network_dict():
...
@@ -197,10 +197,10 @@ def update_network_dict():
def
load_network_dict
():
def
load_network_dict
():
try
:
try
:
my_db
=
db
.
DBConnection
(
'
cache.db
'
)
my_db
=
db
.
DBConnection
(
'
cache.db
'
)
cur_network_list
=
my_db
.
select
(
'
SELECT * FROM network_timezones
'
)
cur_network_list
=
my_db
.
select
(
'
SELECT * FROM network_timezones
;
'
)
if
cur_network_list
is
None
or
len
(
cur_network_list
)
<
1
:
if
cur_network_list
is
None
or
len
(
cur_network_list
)
<
1
:
update_network_dict
()
update_network_dict
()
cur_network_list
=
my_db
.
select
(
'
SELECT * FROM network_timezones
'
)
cur_network_list
=
my_db
.
select
(
'
SELECT * FROM network_timezones
;
'
)
d
=
dict
(
cur_network_list
)
d
=
dict
(
cur_network_list
)
except
:
except
:
d
=
{}
d
=
{}
...
...
This diff is collapsed.
Click to expand it.
sickbeard/scene_exceptions.py
+
11
−
19
View file @
c6d2240a
...
@@ -223,30 +223,22 @@ def retrieve_exceptions():
...
@@ -223,30 +223,22 @@ def retrieve_exceptions():
else
:
else
:
exception_dict
[
anidb_ex
]
=
anidb_exception_dict
[
anidb_ex
]
exception_dict
[
anidb_ex
]
=
anidb_exception_dict
[
anidb_ex
]
changed_exceptions
=
False
queries
=
[]
# write all the exceptions we got off the net into the database
myDB
=
db
.
DBConnection
(
'
cache.db
'
)
myDB
=
db
.
DBConnection
(
'
cache.db
'
)
for
cur_indexer_id
in
exception_dict
:
for
cur_indexer_id
in
exception_dict
:
sql_ex
=
myDB
.
select
(
"
SELECT * FROM scene_exceptions WHERE indexer_id = ?;
"
,
[
cur_indexer_id
])
# get a list of the existing exceptions for this ID
existing_exceptions
=
[
x
[
"
show_name
"
]
for
x
in
sql_ex
]
existing_exceptions
=
[
x
[
"
show_name
"
]
for
x
in
myDB
.
select
(
"
SELECT * FROM scene_exceptions WHERE indexer_id = ?
"
,
[
cur_indexer_id
])]
if
not
cur_indexer_id
in
exception_dict
:
if
not
cur_indexer_id
in
exception_dict
:
continue
continue
for
cur_exception_dict
in
exception_dict
[
cur_indexer_id
]:
for
cur_exception_dict
in
exception_dict
[
cur_indexer_id
]:
cur_exception
,
curSeason
=
cur_exception_dict
.
items
()[
0
]
for
ex
in
cur_exception_dict
.
iteritems
():
cur_exception
,
curSeason
=
ex
# if this exception isn't already in the DB then add it
if
cur_exception
not
in
existing_exceptions
:
if
cur_exception
not
in
existing_exceptions
:
myDB
.
action
(
"
INSERT INTO scene_exceptions (indexer_id, show_name, season) VALUES (?,?,?)
"
,
queries
.
append
([
"
INSERT OR IGNORE INTO scene_exceptions (indexer_id, show_name, season) VALUES (?,?,?);
"
,
[
cur_indexer_id
,
cur_exception
,
curSeason
])
[
cur_indexer_id
,
cur_exception
,
curSeason
]])
changed_exceptions
=
True
if
queries
:
myDB
.
mass_action
(
queries
)
# since this could invalidate the results of the cache we clear it out after updating
if
changed_exceptions
:
logger
.
log
(
u
"
Updated scene exceptions
"
,
logger
.
DEBUG
)
logger
.
log
(
u
"
Updated scene exceptions
"
,
logger
.
DEBUG
)
else
:
else
:
logger
.
log
(
u
"
No scene exceptions update needed
"
,
logger
.
DEBUG
)
logger
.
log
(
u
"
No scene exceptions update needed
"
,
logger
.
DEBUG
)
...
@@ -316,7 +308,7 @@ def _xem_exceptions_fetcher():
...
@@ -316,7 +308,7 @@ def _xem_exceptions_fetcher():
if
parsedJSON
[
'
result
'
]
==
'
failure
'
:
if
parsedJSON
[
'
result
'
]
==
'
failure
'
:
continue
continue
for
indexerid
,
names
in
parsedJSON
[
'
data
'
].
items
():
for
indexerid
,
names
in
parsedJSON
[
'
data
'
].
iter
items
():
try
:
try
:
xem_exception_dict
[
int
(
indexerid
)]
=
names
xem_exception_dict
[
int
(
indexerid
)]
=
names
except
Exception
as
e
:
except
Exception
as
e
:
...
...
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