2018-10-23 22:54:09 +11:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from __future__ import absolute_import, division, unicode_literals
|
2018-10-25 00:20:25 +11:00
|
|
|
from .. import variables as v
|
2018-10-23 22:54:09 +11:00
|
|
|
|
|
|
|
|
|
|
|
class Movies(object):
|
2019-04-27 19:17:29 +10:00
|
|
|
def add_movie(self, plex_id, checksum, section_id, section_uuid, kodi_id,
|
|
|
|
kodi_fileid, kodi_pathid, last_sync):
|
2018-10-23 22:54:09 +11:00
|
|
|
"""
|
|
|
|
Appends or replaces an entry into the plex table for movies
|
|
|
|
"""
|
|
|
|
query = '''
|
|
|
|
INSERT OR REPLACE INTO movie(
|
|
|
|
plex_id,
|
|
|
|
checksum,
|
|
|
|
section_id,
|
2019-04-27 19:17:29 +10:00
|
|
|
section_uuid,
|
2018-10-23 22:54:09 +11:00
|
|
|
kodi_id,
|
|
|
|
kodi_fileid,
|
|
|
|
kodi_pathid,
|
|
|
|
fanart_synced,
|
|
|
|
last_sync)
|
2019-04-27 19:17:29 +10:00
|
|
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
2018-10-23 22:54:09 +11:00
|
|
|
'''
|
2018-10-25 00:20:25 +11:00
|
|
|
self.cursor.execute(
|
2018-10-23 22:54:09 +11:00
|
|
|
query,
|
|
|
|
(plex_id,
|
|
|
|
checksum,
|
|
|
|
section_id,
|
2019-04-27 19:17:29 +10:00
|
|
|
section_uuid,
|
2018-10-23 22:54:09 +11:00
|
|
|
kodi_id,
|
|
|
|
kodi_fileid,
|
|
|
|
kodi_pathid,
|
|
|
|
0,
|
|
|
|
last_sync))
|
|
|
|
|
|
|
|
def movie(self, plex_id):
|
|
|
|
"""
|
|
|
|
Returns the show info as a tuple for the TV show with plex_id:
|
|
|
|
plex_id INTEGER PRIMARY KEY ASC,
|
|
|
|
checksum INTEGER UNIQUE,
|
|
|
|
section_id INTEGER,
|
2019-04-27 19:17:29 +10:00
|
|
|
section_uuid TEXT,
|
2018-10-23 22:54:09 +11:00
|
|
|
kodi_id INTEGER,
|
|
|
|
kodi_fileid INTEGER,
|
|
|
|
kodi_pathid INTEGER,
|
|
|
|
fanart_synced INTEGER,
|
|
|
|
last_sync INTEGER
|
|
|
|
"""
|
2018-10-25 00:20:25 +11:00
|
|
|
if plex_id is None:
|
|
|
|
return
|
|
|
|
self.cursor.execute('SELECT * FROM movie WHERE plex_id = ? LIMIT 1',
|
2018-10-23 22:54:09 +11:00
|
|
|
(plex_id, ))
|
2018-10-25 00:20:25 +11:00
|
|
|
return self.entry_to_movie(self.cursor.fetchone())
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def entry_to_movie(entry):
|
|
|
|
if not entry:
|
|
|
|
return
|
|
|
|
return {
|
|
|
|
'plex_type': v.PLEX_TYPE_MOVIE,
|
|
|
|
'kodi_type': v.KODI_TYPE_MOVIE,
|
|
|
|
'plex_id': entry[0],
|
|
|
|
'checksum': entry[1],
|
|
|
|
'section_id': entry[2],
|
2019-04-27 19:17:29 +10:00
|
|
|
'section_uuid': entry[3],
|
|
|
|
'kodi_id': entry[4],
|
|
|
|
'kodi_fileid': entry[5],
|
|
|
|
'kodi_pathid': entry[6],
|
|
|
|
'fanart_synced': entry[7],
|
|
|
|
'last_sync': entry[8]
|
2018-10-25 00:20:25 +11:00
|
|
|
}
|