Python 2 backport of code
This commit is contained in:
parent
5ca9e78bff
commit
66787dec3e
5 changed files with 34 additions and 12 deletions
|
@ -1,5 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import, division, unicode_literals
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
@ -9,8 +10,10 @@ import xbmcaddon
|
|||
|
||||
# Import the existing Kodi add-on metadata.themoviedb.org.python
|
||||
__ADDON__ = xbmcaddon.Addon(id='metadata.themoviedb.org.python')
|
||||
__TEMP_PATH__ = os.path.join(__ADDON__.getAddonInfo('path'), 'python', 'lib')
|
||||
__BASE__ = xbmcvfs.translatePath(__TEMP_PATH__)
|
||||
__TEMP_PATH__ = os.path.join(__ADDON__.getAddonInfo('path').decode('utf-8'),
|
||||
'python',
|
||||
'lib')
|
||||
__BASE__ = xbmcvfs.translatePath(__TEMP_PATH__.encode('utf-8')).decode('utf-8')
|
||||
sys.path.append(__BASE__)
|
||||
import tmdbscraper.tmdb as tmdb
|
||||
|
||||
|
@ -18,8 +21,8 @@ logger = logging.getLogger('PLEX.movies_tmdb')
|
|||
|
||||
|
||||
def get_tmdb_scraper(settings):
|
||||
language = settings.getSettingString('language')
|
||||
certcountry = settings.getSettingString('tmdbcertcountry')
|
||||
language = settings.getSettingString('language').decode('utf-8')
|
||||
certcountry = settings.getSettingString('tmdbcertcountry').decode('utf-8')
|
||||
return tmdb.TMDBMovieScraper(__ADDON__, language, certcountry)
|
||||
|
||||
|
||||
|
@ -27,8 +30,10 @@ def get_tmdb_scraper(settings):
|
|||
# for every single movie
|
||||
__SCRAPER__ = get_tmdb_scraper(__ADDON__)
|
||||
|
||||
|
||||
def get_tmdb_details(unique_ids):
|
||||
details = __SCRAPER__.get_details(unique_ids)
|
||||
LOG.error('details type. %s', type(details))
|
||||
if 'error' in details:
|
||||
logger.debug('Could not get tmdb details for %s. Error: %s',
|
||||
unique_ids, details)
|
||||
|
|
|
@ -487,7 +487,8 @@ class KodiVideoDB(common.KodiDBBase):
|
|||
self.cursor.execute('SELECT c19 FROM movie WHERE idMovie=?',
|
||||
(kodi_id, ))
|
||||
else:
|
||||
raise NotImplementedError(f'trailers for {kodi_type} not implemented')
|
||||
raise NotImplementedError('trailers for %s not implemented'
|
||||
% kodi_type)
|
||||
try:
|
||||
return self.cursor.fetchone()[0]
|
||||
except TypeError:
|
||||
|
@ -502,7 +503,8 @@ class KodiVideoDB(common.KodiDBBase):
|
|||
self.cursor.execute('UPDATE movie SET c19=? WHERE idMovie=?',
|
||||
(url, kodi_id))
|
||||
else:
|
||||
raise NotImplementedError(f'trailers for {kodi_type} not implemented')
|
||||
raise NotImplementedError('trailers for not implemented'
|
||||
% kodi_type)
|
||||
|
||||
@db.catch_operationalerrors
|
||||
def modify_streams(self, fileid, streamdetails=None, runtime=None):
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import, division, unicode_literals
|
||||
from logging import getLogger
|
||||
|
||||
from . import additional_metadata_tmdb
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import, division, unicode_literals
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
@ -14,8 +15,10 @@ from .. import itemtypes, plex_functions as PF, utils, variables as v
|
|||
|
||||
# Import the existing Kodi add-on metadata.themoviedb.org.python
|
||||
__ADDON__ = xbmcaddon.Addon(id='metadata.themoviedb.org.python')
|
||||
__TEMP_PATH__ = os.path.join(__ADDON__.getAddonInfo('path'), 'python', 'lib')
|
||||
__BASE__ = xbmcvfs.translatePath(__TEMP_PATH__)
|
||||
__TEMP_PATH__ = os.path.join(__ADDON__.getAddonInfo('path').decode('utf-8'),
|
||||
'python',
|
||||
'lib')
|
||||
__BASE__ = xbmcvfs.translatePath(__TEMP_PATH__.encode('utf-8')).decode('utf-8')
|
||||
sys.path.append(__BASE__)
|
||||
import tmdbscraper.tmdb as tmdb
|
||||
|
||||
|
@ -25,8 +28,8 @@ TMDB_SUPPORTED_IDS = ('tmdb', 'imdb')
|
|||
|
||||
|
||||
def get_tmdb_scraper(settings):
|
||||
language = settings.getSettingString('language')
|
||||
certcountry = settings.getSettingString('tmdbcertcountry')
|
||||
language = settings.getSettingString('language').decode('utf-8')
|
||||
certcountry = settings.getSettingString('tmdbcertcountry').decode('utf-8')
|
||||
return tmdb.TMDBMovieScraper(settings, language, certcountry)
|
||||
|
||||
|
||||
|
@ -51,7 +54,7 @@ def process_trailers(plex_id, plex_type, refresh=False):
|
|||
with KodiVideoDB() as kodidb:
|
||||
trailer = kodidb.get_trailer(db_item['kodi_id'],
|
||||
db_item['kodi_type'])
|
||||
if trailer and (trailer.startswith(f'plugin://{v.ADDON_ID}') or
|
||||
if trailer and (trailer.startswith('plugin://' + v.ADDON_ID) or
|
||||
not refresh):
|
||||
# No need to get a trailer
|
||||
return
|
||||
|
|
|
@ -99,4 +99,15 @@ def check_migration():
|
|||
utils.settings('accessToken', value='')
|
||||
utils.settings('plexAvatar', value='')
|
||||
|
||||
# Need to delete the UNIQUE index that prevents creating several
|
||||
# playlist entries with the same kodi_hash
|
||||
if not utils.compare_version(last_migration, '2.12.17'):
|
||||
LOG.info('Migrating to version 2.12.16')
|
||||
# Add an additional column `trailer_synced` in the Plex movie table
|
||||
from .plex_db import PlexDB
|
||||
with PlexDB() as plexdb:
|
||||
query = 'ALTER TABLE movie ADD trailer_synced BOOLEAN'
|
||||
plexdb.cursor.execute(query)
|
||||
# Index will be automatically recreated on next PKC startup
|
||||
|
||||
utils.settings('last_migrated_PKC_version', value=v.ADDON_VERSION)
|
||||
|
|
Loading…
Reference in a new issue