本文整理汇总了Python中salts_lib.db_utils.DB_Connection类的典型用法代码示例。如果您正苦于以下问题:Python DB_Connection类的具体用法?Python DB_Connection怎么用?Python DB_Connection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DB_Connection类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _cached_http_get
def _cached_http_get(self, url, base_url, timeout, cookies=None, data=None, headers=None, cache_limit=8):
if cookies is None: cookies = {}
if timeout == 0: timeout = None
if headers is None: headers = {}
referer = headers['Referer'] if 'Referer' in headers else url
log_utils.log('Getting Url: %s cookie=|%s| data=|%s| extra headers=|%s|' % (url, cookies, data, headers))
db_connection = DB_Connection()
_, html = db_connection.get_cached_url(url, cache_limit)
if html:
log_utils.log('Returning cached result for: %s' % (url), xbmc.LOGDEBUG)
return html
try:
cj = self._set_cookies(base_url, cookies)
if data is not None: data = urllib.urlencode(data, True)
request = urllib2.Request(url, data=data)
request.add_header('User-Agent', USER_AGENT)
request.add_unredirected_header('Host', request.get_host())
request.add_unredirected_header('Referer', referer)
for key in headers: request.add_header(key, headers[key])
response = urllib2.urlopen(request, timeout=timeout)
cj.save(ignore_discard=True, ignore_expires=True)
if response.info().get('Content-Encoding') == 'gzip':
buf = StringIO(response.read())
f = gzip.GzipFile(fileobj=buf)
html = f.read()
else:
html = response.read()
except Exception as e:
log_utils.log('Error (%s) during scraper http get: %s' % (str(e), url), xbmc.LOGWARNING)
return ''
db_connection.cache_url(url, html)
return html
开发者ID:djbijo,项目名称:salts,代码行数:34,代码来源:scraper.py
示例2: __init__
def __init__(self, timeout=scraper.DEFAULT_TIMEOUT):
self.timeout = timeout
self.db_connection = DB_Connection()
self.base_url = xbmcaddon.Addon().getSetting(
'%s-base_url' % (self.get_name()))
self.username = xbmcaddon.Addon().getSetting(
'%s-username' % (self.get_name()))
self.password = xbmcaddon.Addon().getSetting(
'%s-password' % (self.get_name()))
开发者ID:cyberwarrior,项目名称:dmind,代码行数:9,代码来源:directdl_scraper.py
示例3: DB_Connection
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
import xbmc
import xbmcaddon
import xbmcgui
from salts_lib import log_utils
from salts_lib import utils
from salts_lib.constants import MODES
from salts_lib.db_utils import DB_Connection
MAX_ERRORS = 10
ADDON = xbmcaddon.Addon(id='plugin.video.salts')
log_utils.log('Service: Installed Version: %s' % (ADDON.getAddonInfo('version')))
db_connection = DB_Connection()
if ADDON.getSetting('use_remote_db') == 'false' or ADDON.getSetting('enable_upgrade') == 'true':
db_connection.init_database()
class Service(xbmc.Player):
def __init__(self, *args, **kwargs):
log_utils.log('Service: starting...')
xbmc.Player.__init__(self, *args, **kwargs)
self.win = xbmcgui.Window(10000)
self.reset()
def reset(self):
log_utils.log('Service: Resetting...')
self.win.clearProperty('salts.playing')
self.win.clearProperty('salts.playing.slug')
self.win.clearProperty('salts.playing.season')
开发者ID:trickaz,项目名称:tknorris-beta-repo,代码行数:31,代码来源:service.py
示例4: DB_Connection
"""
import xbmc
import xbmcgui
import xbmcaddon
from salts_lib import kodi
from salts_lib import log_utils
from salts_lib import utils
from salts_lib import utils2
from salts_lib.constants import MODES
from salts_lib.constants import TRIG_DB_UPG
from salts_lib.db_utils import DB_Connection
MAX_ERRORS = 10
log_utils.log('Service: Installed Version: %s' % (kodi.get_version()))
db_connection = DB_Connection()
if kodi.get_setting('use_remote_db') == 'false' or kodi.get_setting('enable_upgrade') == 'true':
if TRIG_DB_UPG:
db_version = db_connection.get_db_version()
else:
db_version = kodi.get_version()
db_connection.init_database(db_version)
class Service(xbmc.Player):
def __init__(self, *args, **kwargs):
log_utils.log('Service: starting...')
xbmc.Player.__init__(self, *args, **kwargs)
self.win = xbmcgui.Window(10000)
self.reset()
def reset(self):
开发者ID:assli100,项目名称:kodi-openelec,代码行数:31,代码来源:service.py
示例5: DirectDownload_Scraper
class DirectDownload_Scraper(scraper.Scraper):
base_url = BASE_URL
def __init__(self, timeout=scraper.DEFAULT_TIMEOUT):
self.timeout = timeout
self.db_connection = DB_Connection()
self.base_url = xbmcaddon.Addon().getSetting('%s-base_url' % (self.get_name()))
self.username = xbmcaddon.Addon().getSetting('%s-username' % (self.get_name()))
self.password = xbmcaddon.Addon().getSetting('%s-password' % (self.get_name()))
@classmethod
def provides(cls):
return frozenset([VIDEO_TYPES.EPISODE])
@classmethod
def get_name(cls):
return 'DirectDownload.tv'
def resolve_link(self, link):
return link
def format_source_label(self, item):
return '[%s] (%s) %s' % (item['quality'], item['dd_qual'], item['host'])
def get_sources(self, video):
source_url = self.get_url(video)
hosters = []
if source_url:
url = urlparse.urljoin(self.base_url, source_url)
html = self._http_get(url, cache_limit=.5)
if html:
js_result = json.loads(html)
query = urlparse.parse_qs(urlparse.urlparse(url).query)
match_quality = Q_ORDER
if 'quality' in query:
temp_quality = re.sub('\s', '', query['quality'][0])
match_quality = temp_quality.split(',')
import urlresolver
sxe_str = '.S%02dE%02d.' % (int(video.season), int(video.episode))
airdate_str = video.ep_airdate.strftime('.%Y.%m.%d.')
for result in js_result:
if sxe_str not in result['release'] and airdate_str not in result['release']:
continue
if result['quality'] in match_quality:
for link in result['links']:
if re.search('\.rar(\.|$)', link['url']):
continue
# validate url since host validation fails for real-debrid; mark links direct to avoid unusable check
if urlresolver.HostedMediaFile(link['url']):
hostname = urlparse.urlparse(link['url']).hostname
hoster = {'multi-part': False, 'class': self, 'views': None, 'url': link['url'], 'rating': None, 'host': hostname,
'quality': QUALITY_MAP[result['quality']], 'dd_qual': result['quality'], 'direct': True}
hosters.append(hoster)
return hosters
def get_url(self, video):
url = None
result = self.db_connection.get_related_url(video.video_type, video.title, video.year, self.get_name(), video.season, video.episode)
if result:
url = result[0][0]
log_utils.log('Got local related url: |%s|%s|%s|%s|%s|' % (video.video_type, video.title, video.year, self.get_name(), url))
else:
date_match = False
search_title = '%s S%02dE%02d' % (video.title, int(video.season), int(video.episode))
results = self.search(video.video_type, search_title, '')
if not results and video.ep_airdate is not None:
search_title = '%s %s' % (video.title, video.ep_airdate.strftime('%Y.%m.%d'))
results = self.search(video.video_type, search_title, '')
date_match = True
best_q_index = -1
for result in results:
if date_match and video.ep_airdate.strftime('%Y.%m.%d') not in result['title']:
continue
if Q_DICT[result['quality']] > best_q_index:
best_q_index = Q_DICT[result['quality']]
url = result['url']
self.db_connection.set_related_url(video.video_type, video.title, video.year, self.get_name(), url)
return url
@classmethod
def get_settings(cls):
settings = super(DirectDownload_Scraper, cls).get_settings()
settings = cls._disable_sub_check(settings)
name = cls.get_name()
settings.append(' <setting id="%s-username" type="text" label=" Username" default="" visible="eq(-6,true)"/>' % (name))
settings.append(' <setting id="%s-password" type="text" label=" Password" option="hidden" default="" visible="eq(-7,true)"/>' % (name))
return settings
def search(self, video_type, title, year):
search_url = urlparse.urljoin(self.base_url, '/search?query=')
search_url += title
html = self._http_get(search_url, cache_limit=.25)
results = []
if html:
#.........这里部分代码省略.........
开发者ID:djbijo,项目名称:salts,代码行数:101,代码来源:directdl_scraper.py
示例6: OneClickWatch_Scraper
class OneClickWatch_Scraper(scraper.Scraper):
base_url=BASE_URL
def __init__(self, timeout=scraper.DEFAULT_TIMEOUT):
self.timeout=timeout
self.db_connection = DB_Connection()
self.base_url = xbmcaddon.Addon().getSetting('%s-base_url' % (self.get_name()))
@classmethod
def provides(cls):
return frozenset([VIDEO_TYPES.MOVIE, VIDEO_TYPES.EPISODE])
@classmethod
def get_name(cls):
return 'OneClickWatch'
def resolve_link(self, link):
return link
def format_source_label(self, item):
return '[%s] %s (%s/100)' % (item['quality'], item['host'], item['rating'])
def get_sources(self, video):
source_url= self.get_url(video)
hosters=[]
if source_url:
url = urlparse.urljoin(self.base_url,source_url)
html = self._http_get(url, cache_limit=.5)
q_str = ''
match = re.search('class="title">([^<]+)', html)
if match:
q_str = match.group(1)
pattern = '^<a\s+href="([^"]+)"\s+rel="nofollow"'
for match in re.finditer(pattern, html, re.M):
url=match.group(1)
hoster={'multi-part': False, 'class': self, 'views': None, 'url': url, 'rating': None, 'direct': False}
hoster['host']=urlparse.urlsplit(url).hostname
hoster['quality']=self._blog_get_quality(video, q_str, hoster['host'])
hosters.append(hoster)
return hosters
def get_url(self, video):
url = None
result = self.db_connection.get_related_url(video.video_type, video.title, video.year, self.get_name(), video.season, video.episode)
if result:
url=result[0][0]
log_utils.log('Got local related url: |%s|%s|%s|%s|%s|' % (video.video_type, video.title, video.year, self.get_name(), url))
else:
select = int(xbmcaddon.Addon().getSetting('%s-select' % (self.get_name())))
if video.video_type == VIDEO_TYPES.EPISODE:
search_title = '%s S%02dE%02d' % (video.title, int(video.season), int(video.episode))
else:
search_title = '%s %s' % (video.title, video.year)
results = self.search(video.video_type, search_title, video.year)
if results:
if select == 0:
best_result = results[0]
else:
best_qorder=0
best_qstr=''
for result in results:
match = re.search('\[(.*)\]$', result['title'])
if match:
q_str = match.group(1)
quality=self._blog_get_quality(video, q_str, '')
#print 'result: |%s|%s|%s|%s|' % (result, q_str, quality, Q_ORDER[quality])
if Q_ORDER[quality]>=best_qorder:
if Q_ORDER[quality] > best_qorder or (quality == QUALITIES.HD and '1080' in q_str and '1080' not in best_qstr):
#print 'Setting best as: |%s|%s|%s|%s|' % (result, q_str, quality, Q_ORDER[quality])
best_qstr = q_str
best_result=result
best_qorder = Q_ORDER[quality]
url = best_result['url']
self.db_connection.set_related_url(video.video_type, video.title, video.year, self.get_name(), url)
return url
@classmethod
def get_settings(cls):
settings = super(OneClickWatch_Scraper, cls).get_settings()
settings = cls._disable_sub_check(settings)
name=cls.get_name()
settings.append(' <setting id="%s-filter" type="slider" range="0,180" option="int" label=" Filter results older than (0=No Filter) (days)" default="30" visible="eq(-6,true)"/>' % (name))
settings.append(' <setting id="%s-select" type="enum" label=" Automatically Select (Movies only)" values="Most Recent|Highest Quality" default="0" visible="eq(-7,true)"/>' % (name))
return settings
def search(self, video_type, title, year):
search_url = urlparse.urljoin(self.base_url, '/?s=')
search_url += urllib.quote_plus(title)
html = self._http_get(search_url, cache_limit=.25)
results=[]
filter_days = datetime.timedelta(days=int(xbmcaddon.Addon().getSetting('%s-filter' % (self.get_name()))))
today = datetime.date.today()
pattern ='class="title"><a href="([^"]+)[^>]+>([^<]+).*?rel="bookmark">([^<]+)'
for match in re.finditer(pattern, html, re.DOTALL):
url, title, date_str = match.groups('')
if filter_days:
try: post_date = datetime.datetime.strptime(date_str, '%B %d, %Y').date()
#.........这里部分代码省略.........
开发者ID:trickaz,项目名称:tknorris-beta-repo,代码行数:101,代码来源:oneclickwatch_scraper.py
示例7: __init__
def __init__(self, timeout=DEFAULT_TIMEOUT):
self.db_connection = DB_Connection()
开发者ID:djbijo,项目名称:salts,代码行数:2,代码来源:scraper.py
示例8: Scraper
class Scraper(object):
__metaclass__ = abc.ABCMeta
base_url = BASE_URL
def __init__(self, timeout=DEFAULT_TIMEOUT):
self.db_connection = DB_Connection()
@abstractclassmethod
def provides(cls):
"""
Must return a list/set/frozenset of VIDEO_TYPES that are supported by this scraper. Is a class method so that instances of the class
don't have to be instantiated to determine they are not useful
* Datatypes set or frozenset are preferred as existence checking is faster with sets
"""
raise NotImplementedError
@abstractclassmethod
def get_name(cls):
"""
Must return a string that is a name that will be used through out the UI and DB to refer to urls from this source
Should be descriptive enough to be recognized but short enough to be presented in the UI
"""
raise NotImplementedError
@abc.abstractmethod
def resolve_link(self, link):
"""
Must return a string that is a urlresolver resolvable link given a link that this scraper supports
link: a url fragment associated with this site that can be resolved to a hoster link
* The purpose is many streaming sites provide the actual hoster link in a separate page from link
on the video page.
* This method is called for the user selected source before calling urlresolver on it.
"""
raise NotImplementedError
@abc.abstractmethod
def format_source_label(self, item):
"""
Must return a string that is to be the label to be used for this source in the "Choose Source" dialog
item: one element of the list that is returned from get_sources for this scraper
"""
raise NotImplementedError
@abc.abstractmethod
def get_sources(self, video):
"""
Must return a list of dictionaries that are potential link to hoster sites (or links to links to hoster sites)
Each dictionary must contain elements of at least:
* multi-part: True if this source is one part of a whole
* class: a reference to an instance of the scraper itself
* host: the hostname of the hoster
* url: the url that is a link to a hoster, or a link to a page that this scraper can resolve to a link to a hoster
* quality: one of the QUALITIES values, or None if unknown; users can sort sources by quality
* views: count of the views from the site for this source or None is unknown; Users can sort sources by views
* rating: a value between 0 and 100; 0 being worst, 100 the best, or None if unknown. Users can sort sources by rating.
* direct: True if url is a direct link to a media file; False if not. If not present; assumption is direct
* other keys are allowed as needed if they would be useful (e.g. for format_source_label)
video is an object of type ScraperVideo:
video_type: one of VIDEO_TYPES for whatever the sources should be for
title: the title of the tv show or movie
year: the year of the tv show or movie
season: only present for tv shows; the season number of the video for which sources are requested
episode: only present for tv shows; the episode number of the video for which sources are requested
ep_title: only present for tv shows; the episode title if available
"""
raise NotImplementedError
@abc.abstractmethod
def get_url(self, video):
"""
Must return a url for the site this scraper is associated with that is related to this video.
video is an object of type ScraperVideo:
video_type: one of VIDEO_TYPES this url is for (e.g. EPISODE urls might be different than TVSHOW urls)
title: the title of the tv show or movie
year: the year of the tv show or movie
season: only present for season or episode VIDEO_TYPES; the season number for the url being requested
episode: only present for season or episode VIDEO_TYPES; the episode number for the url being requested
ep_title: only present for tv shows; the episode title if available
* Generally speaking, domain should not be included
"""
raise NotImplementedError
@abc.abstractmethod
def search(self, video_type, title, year):
"""
Must return a list of results returned from the site associated with this scraper when doing a search using the input parameters
If it does return results, it must be a list of dictionaries. Each dictionary must contain at least the following:
* title: title of the result
* year: year of the result
* url: a url fragment that is the url on the site associated with this scraper for this season result item
video_type: one of the VIDEO_TYPES being searched for. Only tvshows and movies are expected generally
#.........这里部分代码省略.........
开发者ID:djbijo,项目名称:salts,代码行数:101,代码来源:scraper.py
示例9: MyVidLinks_Scraper
class MyVidLinks_Scraper(scraper.Scraper):
base_url=BASE_URL
def __init__(self, timeout=scraper.DEFAULT_TIMEOUT):
self.timeout=timeout
self.db_connection = DB_Connection()
self.base_url = xbmcaddon.Addon().getSetting('%s-base_url' % (self.get_name()))
@classmethod
def provides(cls):
return frozenset([VIDEO_TYPES.MOVIE, VIDEO_TYPES.EPISODE])
@classmethod
def get_name(cls):
return 'MyVideoLinks.eu'
def resolve_link(self, link):
return link
def format_source_label(self, item):
return '[%s] %s (%s Views) (%s/100)' % (item['quality'], item['host'], item['views'], item['rating'])
def get_sources(self, video):
source_url= self.get_url(video)
hosters=[]
if source_url:
url = urlparse.urljoin(self.base_url,source_url)
html = self._http_get(url, cache_limit=.5)
views= None
pattern = '<span[^>]+>(\d+)\s+Views'
match = re.search(pattern, html)
if match:
views=int(match.group(1))
if video.video_type == VIDEO_TYPES.MOVIE:
return self.__get_movie_links(video, views, html)
else:
return self.__get_episode_links(video, views, html)
return hosters
def __get_movie_links(self, video, views, html):
pattern = 'rel="bookmark"\s+title="Permanent Link to ([^"]+)'
match = re.search(pattern, html)
q_str = ''
if match:
q_str=match.group(1)
return self.__get_links(video, views, html, q_str)
def __get_episode_links(self, video, views, html):
pattern = '<h4>(.*?)</h4>(.*?)</ul>'
hosters=[]
for match in re.finditer(pattern, html, re.DOTALL):
q_str, fragment = match.groups()
hosters += self.__get_links(video, views, fragment, q_str)
return hosters
def __get_links(self, video, views, html, q_str):
pattern = 'li>\s*<a\s+href="(http[^"]+)'
hosters=[]
for match in re.finditer(pattern, html):
url=match.group(1)
hoster={'multi-part': False, 'class': self, 'views': views, 'url': url, 'rating': None, 'quality': None, 'direct': False}
hoster['host']=urlparse.urlsplit(url).hostname
hoster['quality']=self._blog_get_quality(video, q_str, hoster['host'])
hosters.append(hoster)
return hosters
def get_url(self, video):
url = None
result = self.db_connection.get_related_url(video.video_type, video.title, video.year, self.get_name(), video.season, video.episode)
if result:
url=result[0][0]
log_utils.log('Got local related url: |%s|%s|%s|%s|%s|' % (video.video_type, video.title, video.year, self.get_name(), url))
else:
select = int(xbmcaddon.Addon().getSetting('%s-select' % (self.get_name())))
if video.video_type == VIDEO_TYPES.EPISODE:
search_title = '%s S%02dE%02d' % (video.title, int(video.season), int(video.episode))
else:
search_title = '%s %s' % (video.title, video.year)
results = self.search(video.video_type, search_title, video.year)
if results:
# episodes don't tell us the quality on the search screen so just return the 1st result
if select == 0 or video.video_type == VIDEO_TYPES.EPISODE:
best_result = results[0]
else:
best_qorder=0
best_qstr=''
for result in results:
match = re.search('\[(.*)\]$', result['title'])
if match:
q_str = match.group(1)
quality=self._blog_get_quality(video, q_str, '')
#print 'result: |%s|%s|%s|%s|' % (result, q_str, quality, Q_ORDER[quality])
if Q_ORDER[quality]>=best_qorder:
if Q_ORDER[quality] > best_qorder or (quality == QUALITIES.HD and '1080' in q_str and '1080' not in best_qstr):
#print 'Setting best as: |%s|%s|%s|%s|' % (result, q_str, quality, Q_ORDER[quality])
best_qstr = q_str
best_result=result
best_qorder = Q_ORDER[quality]
#.........这里部分代码省略.........
开发者ID:trickaz,项目名称:tknorris-beta-repo,代码行数:101,代码来源:myvideolinks_scraper.py
示例10: __init__
def __init__(self, *args, **kwargs):
logger.log('Service: starting...', log_utils.LOGNOTICE)
self.db_connection = DB_Connection()
xbmc.Player.__init__(self, *args, **kwargs)
self.win = xbmcgui.Window(10000)
self.reset()
开发者ID:CYBERxNUKE,项目名称:xbmc-addon,代码行数:6,代码来源:service.py
示例11: Service
class Service(xbmc.Player):
def __init__(self, *args, **kwargs):
logger.log('Service: starting...', log_utils.LOGNOTICE)
self.db_connection = DB_Connection()
xbmc.Player.__init__(self, *args, **kwargs)
self.win = xbmcgui.Window(10000)
self.reset()
def reset(self):
logger.log('Service: Resetting...', log_utils.LOGDEBUG)
self.win.clearProperty('salts.playing')
self.win.clearProperty('salts.playing.trakt_id')
self.win.clearProperty('salts.playing.season')
self.win.clearProperty('salts.playing.episode')
self.win.clearProperty('salts.playing.srt')
self.win.clearProperty('salts.playing.trakt_resume')
self.win.clearProperty('salts.playing.salts_resume')
self.win.clearProperty('salts.playing.library')
self._from_library = False
self.tracked = False
self._totalTime = 999999
self.trakt_id = None
self.season = None
self.episode = None
self._lastPos = 0
def onPlayBackStarted(self):
logger.log('Service: Playback started', log_utils.LOGNOTICE)
playing = self.win.getProperty('salts.playing') == 'True'
self.trakt_id = self.win.getProperty('salts.playing.trakt_id')
self.season = self.win.getProperty('salts.playing.season')
self.episode = self.win.getProperty('salts.playing.episode')
srt_path = self.win.getProperty('salts.playing.srt')
trakt_resume = self.win.getProperty('salts.playing.trakt_resume')
salts_resume = self.win.getProperty('salts.playing.salts_resume')
self._from_library = self.win.getProperty('salts.playing.library') == 'True'
if playing: # Playback is ours
logger.log('Service: tracking progress...', log_utils.LOGNOTICE)
self.tracked = True
if srt_path:
logger.log('Service: Enabling subtitles: %s' % (srt_path), log_utils.LOGDEBUG)
self.setSubtitles(srt_path)
else:
self.showSubtitles(False)
self._totalTime = 0
while self._totalTime == 0:
try:
self._totalTime = self.getTotalTime()
except RuntimeError:
self._totalTime = 0
break
kodi.sleep(1000)
if salts_resume:
logger.log("Salts Local Resume: Resume Time: %s Total Time: %s" % (salts_resume, self._totalTime), log_utils.LOGDEBUG)
self.seekTime(float(salts_resume))
elif trakt_resume:
resume_time = float(trakt_resume) * self._totalTime / 100
logger.log("Salts Trakt Resume: Percent: %s, Resume Time: %s Total Time: %s" % (trakt_resume, resume_time, self._totalTime), log_utils.LOGDEBUG)
self.seekTime(resume_time)
def onPlayBackStopped(self):
logger.log('Service: Playback Stopped', log_utils.LOGNOTICE)
if self.tracked:
# clear the playlist if SALTS was playing and only one item in playlist to
# use playlist to determine playback method in get_sources
pl = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
plugin_url = 'plugin://%s/' % (kodi.get_id())
if pl.size() == 1 and pl[0].getfilename().lower().startswith(plugin_url):
logger.log('Service: Clearing Single Item SALTS Playlist', log_utils.LOGDEBUG)
pl.clear()
playedTime = float(self._lastPos)
try: percent_played = int((playedTime / self._totalTime) * 100)
except: percent_played = 0 # guard div by zero
pTime = utils.format_time(playedTime)
tTime = utils.format_time(self._totalTime)
logger.log('Service: Played %s of %s total = %s%%' % (pTime, tTime, percent_played), log_utils.LOGDEBUG)
if playedTime == 0 and self._totalTime == 999999:
logger.log('Kodi silently failed to start playback', log_utils.LOGWARNING)
elif playedTime >= 5:
if percent_played <= 98:
logger.log('Service: Setting bookmark on |%s|%s|%s| to %s seconds' % (self.trakt_id, self.season, self.episode, playedTime), log_utils.LOGDEBUG)
self.db_connection.set_bookmark(self.trakt_id, playedTime, self.season, self.episode)
if percent_played >= 75 and self._from_library:
if kodi.has_addon('script.trakt'):
run = 'RunScript(script.trakt, action=sync, silent=True)'
xbmc.executebuiltin(run)
self.reset()
def onPlayBackEnded(self):
logger.log('Service: Playback completed', log_utils.LOGNOTICE)
self.onPlayBackStopped()
开发者ID:CYBERxNUKE,项目名称:xbmc-addon,代码行数:95,代码来源:service.py
注:本文中的salts_lib.db_utils.DB_Connection类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论