def get_calendar_episodes(self, startdate=0, days=1, user=True): # Broaden date range in case utc conversion bumps into different day mod_date = try_int(startdate) - 1 mod_days = try_int(days) + 2 date = get_datetime_today() + get_timedelta(days=mod_date) return self.get_calendar('shows', user, start_date=date.strftime('%Y-%m-%d'), days=mod_days)
def _get_basedir_calendar(info=None): items = [] today = get_datetime_today() for i in _get_basedir_calendar_items(): if info not in i['info_types']: continue date = today + get_timedelta( days=i.get('params', {}).get('startdate', 0)) i['label'] = i['label'].format(weekday=date.strftime('%A')) i['params']['info'] = info items.append(i) return items
def run(self): self.xbmc_monitor.waitForAbort(600) # Wait 10 minutes before doing updates to give boot time if self.xbmc_monitor.abortRequested(): del self.xbmc_monitor return self.next_time = get_datetime_combine(get_datetime_today(), get_datetime_time(try_int(self.update_hour))) # Get today at hour self.last_time = xbmc.getInfoLabel('Skin.String(TMDbHelper.AutoUpdate.LastTime)') # Get last update self.last_time = convert_timestamp(self.last_time) if self.last_time else None if self.last_time and self.last_time > self.next_time: self.next_time += get_timedelta(hours=24) # Already updated today so set for tomorrow while not self.xbmc_monitor.abortRequested() and not self.exit and self.poll_time: if ADDON.getSettingBool('library_autoupdate'): if get_datetime_now() > self.next_time: # Scheduled time has past so lets update xbmc.executebuiltin('RunScript(plugin.video.themoviedb.helper,library_autoupdate)') xbmc.executebuiltin('Skin.SetString(TMDbHelper.AutoUpdate.LastTime,{})'.format(get_datetime_now().strftime("%Y-%m-%dT%H:%M:%S"))) self.next_time += get_timedelta(hours=24) # Set next update for tomorrow self.xbmc_monitor.waitForAbort(self.poll_time) del self.xbmc_monitor