Skip to content

Commit

Permalink
unicode fix
Browse files Browse the repository at this point in the history
  • Loading branch information
primaeval committed May 26, 2017
1 parent ab10fd9 commit 8e1a97a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 2 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ def clear_database():
c = conn.cursor()
c.execute('DROP TABLE streams')
c.execute('DROP TABLE links')
c.execute('CREATE TABLE IF NOT EXISTS streams (title TEXT, file TEXT, date TIMESTAMP, PRIMARY KEY(file))')
c.execute('CREATE TABLE IF NOT EXISTS links (title TEXT, file TEXT, date TIMESTAMP, PRIMARY KEY(file))')
conn.commit()
conn.close()

Expand Down
7 changes: 2 additions & 5 deletions service.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,25 @@ def onPlayBackStopped(self):
retry = 0
while not path and retry < 50:
path = xbmc.getInfoLabel('ListItem.FileNameAndPath')
#log(("PPP",path))
retry=retry+1
time.sleep(0.1)
label = xbmc.getInfoLabel('ListItem.Label')
#log(("ZZZ",label,path))

conn = sqlite3.connect(xbmc.translatePath('special://profile/addon_data/%s/replay.db' % addon_id()), detect_types=sqlite3.PARSE_DECLTYPES)
sqlite3.register_adapter(datetime.datetime, adapt_datetime)
sqlite3.register_converter('timestamp', convert_datetime)
c = conn.cursor()
if path:
c.execute("INSERT OR REPLACE INTO links VALUES (?,?,?)", (label,path,datetime.datetime.now()))
c.execute("INSERT OR REPLACE INTO links VALUES (?,?,?)", (label.decode("utf8"),path,datetime.datetime.now()))
conn.commit()
conn.close()

def onPlayBackStarted(self):
file = self.getPlayingFile()
#log(file)
try:
response = RPC.player.get_item(playerid=1, properties=["title", "year", "thumbnail", "fanart", "showtitle", "season", "episode"])
except:
return
#log(response)
item = response["item"]
conn = sqlite3.connect(xbmc.translatePath('special://profile/addon_data/%s/replay.db' % addon_id()), detect_types=sqlite3.PARSE_DECLTYPES)
sqlite3.register_adapter(datetime.datetime, adapt_datetime)
Expand Down

0 comments on commit 8e1a97a

Please sign in to comment.