def build(): print("Building library. NO videos are being fetched.") print("-" * 50) Api.discover() connected = Api.selectDevice() if not connected: logger.exception("NOT CONNECTED") # don't think we'll need this # _build_guide() _build_recordings()
def background(self): if not self._background: self._background = \ self.data.get('background_image') and \ Api.images(self.data['background_image']['image_id']) \ or '' return self._background
def thumb(self): if not self._thumb: try: if self.data.get('thumbnail_image'): self._thumb = \ Api.images(self.data['thumbnail_image']['image_id']) self._thumbHasTitle = \ self.data['thumbnail_image']['has_title'] except Exception: logger.debug(f"thumb img: {self.data['thumbnail_image']}") self._thumbHasTitle = False return self._thumb
def gridAiring(self): if not self._gridAiring: data = Api(self.path).get() if 'episode' in data: self._gridAiring = Airing(data, 'episode') elif 'movie_airing' in data: self._gridAiring = Airing(data, 'movie') elif 'event' in data: self._gridAiring = Airing(data, 'event') elif 'program' in data: self._gridAiring = Airing(data, 'program') return self._gridAiring
def _build_guide(): guide_path = built_ins['db']['guide'] if not built_ins['dry_run']: try: os.unlink(guide_path) except Exception: pass guide_db = {} if not built_ins['dry_run']: guide_db = TinyDB(guide_path) # Load all the shows print('Loading All Guide/Show data') sections = Api.views('guide').shows.get() total = sum(len(section.get('contents')) for section in sections) print(f"Total Shows: {total}") for section in sections: contents = section.get('contents') if not contents: logger.info(f"Section {section.get('key').upper()} (0)") continue logger.info(f"Section {section.get('key').upper()} ({len(contents)})") for piece in chunks(contents, MAX_BATCH): shows = Api.batch.post(piece) for path, data in shows.items(): show = Show.newFromData(data) if not built_ins['dry_run']: guide_db.insert({ 'id': show.object_id, 'path': show.path, 'data': show.data, 'version': Api.device.version })
def _airings(self): return Api(self.path).airings.get()
def channel(self): channelPath = self.data['airing_details']['channel_path'] if not self._channel: self._channel = Channel(Api(channelPath).getCached()) return self._channel
def schedule(self, rule='none'): data = Api(self.path).patch(schedule=rule) self.scheduleRule = \ data.get('schedule_rule') != 'none' and \ data.get('schedule_rule') \ or None
def update(self): self.__init__(Api(self.path).get())
def secondsToEnd(self, start=None): start = start or Api.now() return compat.timedelta_total_seconds(self.datetimeEnd - start)
def thumb(self): if not self._thumb: image = self.thumbnail_image and \ Api.images(self.thumbnail_image['image_id']) self._thumb = image or '' return self._thumb
def deleteAll(self, delete_protected=False): if delete_protected: return Api(self.path)('delete').post() else: return Api(self.path)('delete').post(filter='unprotected')
def seasons(self): try: return Api(self.path).seasons.get() except APIError as e: logger.error(f'Series.seasons() failed: {format(e.message)}') return []
def background(self): if not self._background: image = self.background_image and \ Api.images(self.background_image['image_id']) self._background = image or '' return self._background
def secondsToStart(self): return compat.timedelta_total_seconds(self.datetime - Api.now())
def delete(self): self.deleted = True return Api(self.path).delete()
def ended(self): return self.datetimeEnd < Api.now()
def airingNow(self, ref=None): ref = ref or Api.now() return self.datetime <= ref < self.datetimeEnd
def secondsSinceEnd(self): return compat.timedelta_total_seconds(Api.now() - self.datetimeEnd)
def show(self): if not self._show: info = Api(self.showPath).get() self._show = Show.newFromData(info) return self._show
def episodes(self): return Api(self.path).episodes.get()