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
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, unicode_literals
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
@ -9,8 +10,10 @@ import xbmcaddon
|
||||||
|
|
||||||
# Import the existing Kodi add-on metadata.themoviedb.org.python
|
# Import the existing Kodi add-on metadata.themoviedb.org.python
|
||||||
__ADDON__ = xbmcaddon.Addon(id='metadata.themoviedb.org.python')
|
__ADDON__ = xbmcaddon.Addon(id='metadata.themoviedb.org.python')
|
||||||
__TEMP_PATH__ = os.path.join(__ADDON__.getAddonInfo('path'), 'python', 'lib')
|
__TEMP_PATH__ = os.path.join(__ADDON__.getAddonInfo('path').decode('utf-8'),
|
||||||
__BASE__ = xbmcvfs.translatePath(__TEMP_PATH__)
|
'python',
|
||||||
|
'lib')
|
||||||
|
__BASE__ = xbmcvfs.translatePath(__TEMP_PATH__.encode('utf-8')).decode('utf-8')
|
||||||
sys.path.append(__BASE__)
|
sys.path.append(__BASE__)
|
||||||
import tmdbscraper.tmdb as tmdb
|
import tmdbscraper.tmdb as tmdb
|
||||||
|
|
||||||
|
@ -18,8 +21,8 @@ logger = logging.getLogger('PLEX.movies_tmdb')
|
||||||
|
|
||||||
|
|
||||||
def get_tmdb_scraper(settings):
|
def get_tmdb_scraper(settings):
|
||||||
language = settings.getSettingString('language')
|
language = settings.getSettingString('language').decode('utf-8')
|
||||||
certcountry = settings.getSettingString('tmdbcertcountry')
|
certcountry = settings.getSettingString('tmdbcertcountry').decode('utf-8')
|
||||||
return tmdb.TMDBMovieScraper(__ADDON__, language, certcountry)
|
return tmdb.TMDBMovieScraper(__ADDON__, language, certcountry)
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,8 +30,10 @@ def get_tmdb_scraper(settings):
|
||||||
# for every single movie
|
# for every single movie
|
||||||
__SCRAPER__ = get_tmdb_scraper(__ADDON__)
|
__SCRAPER__ = get_tmdb_scraper(__ADDON__)
|
||||||
|
|
||||||
|
|
||||||
def get_tmdb_details(unique_ids):
|
def get_tmdb_details(unique_ids):
|
||||||
details = __SCRAPER__.get_details(unique_ids)
|
details = __SCRAPER__.get_details(unique_ids)
|
||||||
|
LOG.error('details type. %s', type(details))
|
||||||
if 'error' in details:
|
if 'error' in details:
|
||||||
logger.debug('Could not get tmdb details for %s. Error: %s',
|
logger.debug('Could not get tmdb details for %s. Error: %s',
|
||||||
unique_ids, details)
|
unique_ids, details)
|
||||||
|
|
|
@ -487,7 +487,8 @@ class KodiVideoDB(common.KodiDBBase):
|
||||||
self.cursor.execute('SELECT c19 FROM movie WHERE idMovie=?',
|
self.cursor.execute('SELECT c19 FROM movie WHERE idMovie=?',
|
||||||
(kodi_id, ))
|
(kodi_id, ))
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError(f'trailers for {kodi_type} not implemented')
|
raise NotImplementedError('trailers for %s not implemented'
|
||||||
|
% kodi_type)
|
||||||
try:
|
try:
|
||||||
return self.cursor.fetchone()[0]
|
return self.cursor.fetchone()[0]
|
||||||
except TypeError:
|
except TypeError:
|
||||||
|
@ -502,7 +503,8 @@ class KodiVideoDB(common.KodiDBBase):
|
||||||
self.cursor.execute('UPDATE movie SET c19=? WHERE idMovie=?',
|
self.cursor.execute('UPDATE movie SET c19=? WHERE idMovie=?',
|
||||||
(url, kodi_id))
|
(url, kodi_id))
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError(f'trailers for {kodi_type} not implemented')
|
raise NotImplementedError('trailers for not implemented'
|
||||||
|
% kodi_type)
|
||||||
|
|
||||||
@db.catch_operationalerrors
|
@db.catch_operationalerrors
|
||||||
def modify_streams(self, fileid, streamdetails=None, runtime=None):
|
def modify_streams(self, fileid, streamdetails=None, runtime=None):
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, unicode_literals
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
|
|
||||||
from . import additional_metadata_tmdb
|
from . import additional_metadata_tmdb
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, unicode_literals
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
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
|
# Import the existing Kodi add-on metadata.themoviedb.org.python
|
||||||
__ADDON__ = xbmcaddon.Addon(id='metadata.themoviedb.org.python')
|
__ADDON__ = xbmcaddon.Addon(id='metadata.themoviedb.org.python')
|
||||||
__TEMP_PATH__ = os.path.join(__ADDON__.getAddonInfo('path'), 'python', 'lib')
|
__TEMP_PATH__ = os.path.join(__ADDON__.getAddonInfo('path').decode('utf-8'),
|
||||||
__BASE__ = xbmcvfs.translatePath(__TEMP_PATH__)
|
'python',
|
||||||
|
'lib')
|
||||||
|
__BASE__ = xbmcvfs.translatePath(__TEMP_PATH__.encode('utf-8')).decode('utf-8')
|
||||||
sys.path.append(__BASE__)
|
sys.path.append(__BASE__)
|
||||||
import tmdbscraper.tmdb as tmdb
|
import tmdbscraper.tmdb as tmdb
|
||||||
|
|
||||||
|
@ -25,8 +28,8 @@ TMDB_SUPPORTED_IDS = ('tmdb', 'imdb')
|
||||||
|
|
||||||
|
|
||||||
def get_tmdb_scraper(settings):
|
def get_tmdb_scraper(settings):
|
||||||
language = settings.getSettingString('language')
|
language = settings.getSettingString('language').decode('utf-8')
|
||||||
certcountry = settings.getSettingString('tmdbcertcountry')
|
certcountry = settings.getSettingString('tmdbcertcountry').decode('utf-8')
|
||||||
return tmdb.TMDBMovieScraper(settings, language, certcountry)
|
return tmdb.TMDBMovieScraper(settings, language, certcountry)
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,7 +54,7 @@ def process_trailers(plex_id, plex_type, refresh=False):
|
||||||
with KodiVideoDB() as kodidb:
|
with KodiVideoDB() as kodidb:
|
||||||
trailer = kodidb.get_trailer(db_item['kodi_id'],
|
trailer = kodidb.get_trailer(db_item['kodi_id'],
|
||||||
db_item['kodi_type'])
|
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):
|
not refresh):
|
||||||
# No need to get a trailer
|
# No need to get a trailer
|
||||||
return
|
return
|
||||||
|
|
|
@ -99,4 +99,15 @@ def check_migration():
|
||||||
utils.settings('accessToken', value='')
|
utils.settings('accessToken', value='')
|
||||||
utils.settings('plexAvatar', 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)
|
utils.settings('last_migrated_PKC_version', value=v.ADDON_VERSION)
|
||||||
|
|
Loading…
Reference in a new issue