Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions sickbeard/db.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# Author: Nic Wolfe <nic@wolfeden.ca>
# URL: http://code.google.com/p/sickbeard/
#
Expand Down Expand Up @@ -51,6 +52,14 @@ def dbFilename(filename="sickbeard.db", suffix=None):
filename = "%s.%s" % (filename, suffix)
return ek.ek(os.path.join, sickbeard.DATA_DIR, filename)

# functions for sqlite UDFs
def _udf_dropspecialchars(text):
reps = {'á':'a', 'ã':'a', 'â':'a', 'é':'e', 'ê':'e', 'í':'i','ó':'o' ,'õ':'o' ,'ô':'o','ú':'u', 'ç':'c', 'ä':'ae', 'ü':'ue', 'ö':'oe', 'ß':'ss'}
text = text.lower()
for a, b in reps.iteritems():
text = text.replace(a, b)
return text

class DBConnection:
def __init__(self, filename="sickbeard.db", suffix=None, row_type=None):

Expand All @@ -60,6 +69,7 @@ def __init__(self, filename="sickbeard.db", suffix=None, row_type=None):
self.connection.row_factory = self._dict_factory
else:
self.connection.row_factory = sqlite3.Row
self.connection.create_function('dropspecialchars', 1, _udf_dropspecialchars)

def checkDBVersion(self):
try:
Expand Down
2 changes: 1 addition & 1 deletion sickbeard/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def searchDBForShow(regShowName):

for showName in showNames:

sqlResults = myDB.select("SELECT * FROM tv_shows WHERE show_name LIKE ? OR tvr_name LIKE ?", [showName, showName])
sqlResults = myDB.select("SELECT * FROM tv_shows WHERE dropspecialchars(show_name) LIKE dropspecialchars(?) OR dropspecialchars(tvr_name) LIKE dropspecialchars(?)", [showName, showName])

if len(sqlResults) == 1:
return (int(sqlResults[0]["tvdb_id"]), sqlResults[0]["show_name"])
Expand Down