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
a24520f4
Commit
a24520f4
authored
Oct 21, 2018
by
echel0n
Browse files
Added code to strip accents from show names and add as a possible show match
parent
147e412b
Changes
5
Hide whitespace changes
Inline
Side-by-side
changelog.md
View file @
a24520f4
# Changelog
-
*
4be64d5 - 2018-10-21: Release v9.3.98
-
*
c4e7cda - 2018-10-21: Added code to strip accents from show names and add as a possible show match
-
*
e3b3be9 - 2018-10-21: Release v9.3.98
-
*
d5ec001 - 2018-10-21: Fixed issues with matching shows with parsed results when containing accents
-
*
84de9fe - 2018-10-21: Release v9.3.97
-
*
a5f7b6a - 2018-10-21: Fixed issues with network timezones
...
...
sickrage/core/__init__.py
View file @
a24520f4
...
...
@@ -343,9 +343,10 @@ class Core(object):
IntervalTrigger
(
hours
=
self
.
config
.
version_updater_freq
),
next_run_time
=
datetime
.
datetime
.
now
(),
name
=
self
.
version_updater
.
name
,
id
=
self
.
version_updater
.
name
)
.
func
()
)
# add network timezones updater job
self
.
scheduler
.
add_job
(
...
...
@@ -353,9 +354,10 @@ class Core(object):
IntervalTrigger
(
days
=
1
),
next_run_time
=
datetime
.
datetime
.
now
(),
name
=
"TZUPDATER"
,
id
=
"TZUPDATER"
)
.
func
()
)
# add show updater job
self
.
scheduler
.
add_job
(
...
...
sickrage/core/caches/name_cache.py
View file @
a24520f4
...
...
@@ -20,6 +20,7 @@
from
__future__
import
unicode_literals
import
time
import
unicodedata
from
datetime
import
datetime
,
timedelta
from
CodernityDB.database
import
RecordNotFound
...
...
@@ -125,6 +126,27 @@ class NameCache(object):
self
.
last_update
[
show
.
name
]
=
datetime
.
fromtimestamp
(
int
(
time
.
mktime
(
datetime
.
today
().
timetuple
())))
self
.
clear
(
show
.
indexerid
)
show_names
=
[]
for
curSeason
in
[
-
1
]
+
get_scene_seasons
(
show
.
indexerid
):
for
name
in
list
(
set
(
get_scene_exceptions
(
show
.
indexerid
,
season
=
curSeason
)
+
[
show
.
name
])):
self
.
put
(
name
,
show
.
indexerid
)
show_names
.
append
(
name
)
# strip accents
try
:
try
:
name
.
decode
(
'ascii'
)
except
UnicodeEncodeError
:
pass
show_names
.
append
(
unicodedata
.
normalize
(
'NFKD'
,
name
).
encode
(
'ASCII'
,
'ignore'
)
)
show_names
.
append
(
unicodedata
.
normalize
(
'NFKD'
,
name
).
encode
(
'ASCII'
,
'ignore'
).
replace
(
"'"
,
" "
)
)
except
UnicodeDecodeError
:
pass
for
show_name
in
set
(
show_names
):
self
.
put
(
show_name
,
show
.
indexerid
)
\ No newline at end of file
sickrage/core/helpers/show_names.py
View file @
a24520f4
...
...
@@ -21,6 +21,7 @@ from __future__ import unicode_literals
import
fnmatch
import
os
import
re
import
unicodedata
from
datetime
import
date
from
functools
import
partial
...
...
@@ -309,19 +310,30 @@ def allPossibleShowNames(show, season=-1):
:rtype: list[unicode]
"""
show
N
ames
=
get_scene_exceptions
(
show
.
indexerid
,
season
=
season
)[:]
if
not
show
N
ames
:
# if we dont have any season specific exceptions fallback to generic exceptions
show
_n
ames
=
get_scene_exceptions
(
show
.
indexerid
,
season
=
season
)[:]
if
not
show
_n
ames
:
# if we dont have any season specific exceptions fallback to generic exceptions
season
=
-
1
show
N
ames
=
get_scene_exceptions
(
show
.
indexerid
,
season
=
season
)[:]
show
_n
ames
=
get_scene_exceptions
(
show
.
indexerid
,
season
=
season
)[:]
if
season
in
[
-
1
,
1
]:
showNames
.
append
(
show
.
name
)
show_names
.
append
(
show
.
name
)
try
:
# strip accents
try
:
show
.
name
.
decode
(
'ascii'
)
except
UnicodeEncodeError
:
pass
show_names
.
append
(
unicodedata
.
normalize
(
'NFKD'
,
show
.
name
).
encode
(
'ASCII'
,
'ignore'
))
show_names
.
append
(
unicodedata
.
normalize
(
'NFKD'
,
show
.
name
).
encode
(
'ASCII'
,
'ignore'
).
replace
(
"'"
,
" "
))
except
UnicodeDecodeError
:
pass
if
not
show
.
is_anime
:
new
S
how
N
ames
=
[]
new
_s
how
_n
ames
=
[]
country_list
=
countryList
country_list
.
update
(
dict
(
zip
(
countryList
.
values
(),
countryList
.
keys
())))
for
curName
in
set
(
show
N
ames
):
for
curName
in
set
(
show
_n
ames
):
if
not
curName
:
continue
...
...
@@ -330,16 +342,16 @@ def allPossibleShowNames(show, season=-1):
# (and vice versa)
for
curCountry
in
country_list
:
if
curName
.
endswith
(
' '
+
curCountry
):
new
S
how
N
ames
.
append
(
curName
.
replace
(
' '
+
curCountry
,
' ('
+
country_list
[
curCountry
]
+
')'
))
new
_s
how
_n
ames
.
append
(
curName
.
replace
(
' '
+
curCountry
,
' ('
+
country_list
[
curCountry
]
+
')'
))
elif
curName
.
endswith
(
' ('
+
curCountry
+
')'
):
new
S
how
N
ames
.
append
(
curName
.
replace
(
' ('
+
curCountry
+
')'
,
' ('
+
country_list
[
curCountry
]
+
')'
))
new
_s
how
_n
ames
.
append
(
curName
.
replace
(
' ('
+
curCountry
+
')'
,
' ('
+
country_list
[
curCountry
]
+
')'
))
# # if we have "Show Name (2013)" this will strip the (2013) show year from the show name
# new
S
how
N
ames.append(re.sub('\(\d{4}\)', '', curName))
# new
_s
how
_n
ames.append(re.sub('\(\d{4}\)', '', curName))
show
N
ames
+=
new
S
how
N
ames
show
_n
ames
+=
new
_s
how
_n
ames
return
show
N
ames
return
list
(
set
(
show
_n
ames
))
def
determineReleaseName
(
dir_name
=
None
,
nzb_name
=
None
):
...
...
sickrage/core/nameparser/__init__.py
View file @
a24520f4
...
...
@@ -60,26 +60,38 @@ class NameParser(object):
def
get_show
(
self
,
name
):
show
=
None
show_id
=
None
show_names
=
[
name
]
if
not
all
([
name
,
sickrage
.
app
.
showlist
]):
return
show
,
show_id
def
cache_lookup
(
show_name
):
return
sickrage
.
app
.
name_cache
.
get
(
show_name
)
def
cache_lookup
(
term
):
return
sickrage
.
app
.
name_cache
.
get
(
term
)
def
scene_exception_lookup
(
show_name
):
return
get_scene_exception_by_name
(
show_name
)[
0
]
def
scene_exception_lookup
(
term
):
return
get_scene_exception_by_name
(
term
)[
0
]
def
indexer_lookup
(
show_name
):
show_id1
=
int
(
IndexerApi
().
searchForShowID
(
full_sanitizeSceneName
(
show_name
))[
2
])
show_id2
=
int
(
srTraktAPI
()[
'search'
].
query
(
full_sanitizeSceneName
(
show_name
),
'show'
)[
0
].
ids
[
'tvdb'
])
def
indexer_lookup
(
term
):
show_id1
=
int
(
IndexerApi
().
searchForShowID
(
full_sanitizeSceneName
(
term
))[
2
])
show_id2
=
int
(
srTraktAPI
()[
'search'
].
query
(
full_sanitizeSceneName
(
term
),
'show'
)[
0
].
ids
[
'tvdb'
])
return
(
None
,
show_id1
)[
show_id1
==
show_id2
]
for
x
in
[
unicodedata
.
normalize
(
'NFKD'
,
name
).
encode
(
'ASCII'
,
'ignore'
),
name
]:
try
:
# strip accents
try
:
name
.
decode
(
'ascii'
)
except
UnicodeEncodeError
:
pass
show_names
.
append
(
unicodedata
.
normalize
(
'NFKD'
,
name
).
encode
(
'ASCII'
,
'ignore'
))
show_names
.
append
(
unicodedata
.
normalize
(
'NFKD'
,
name
).
encode
(
'ASCII'
,
'ignore'
).
replace
(
"'"
,
" "
))
except
UnicodeDecodeError
:
pass
for
show_name
in
set
(
show_names
):
lookup_list
=
[
lambda
:
cache_lookup
(
x
),
lambda
:
scene_exception_lookup
(
x
),
lambda
:
indexer_lookup
(
x
),
lambda
:
cache_lookup
(
show_name
),
lambda
:
scene_exception_lookup
(
show_name
),
lambda
:
indexer_lookup
(
show_name
),
]
# lookup show id
...
...
@@ -92,7 +104,7 @@ class NameParser(object):
if
show_id
==
0
:
continue
sickrage
.
app
.
name_cache
.
put
(
x
,
show_id
)
sickrage
.
app
.
name_cache
.
put
(
show_name
,
show_id
)
if
self
.
validate_show
:
show
=
findCertainShow
(
show_id
)
else
:
...
...
@@ -103,7 +115,7 @@ class NameParser(object):
if
show_id
is
None
:
# ignore show name by caching it with a indexerid of 0
sickrage
.
app
.
name_cache
.
put
(
x
,
0
)
sickrage
.
app
.
name_cache
.
put
(
show_name
,
0
)
return
show
,
show_id
or
0
...
...
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