コード例 #1
0
ファイル: library.py プロジェクト: jessedp/tut
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()
コード例 #2
0
 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
コード例 #3
0
 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
コード例 #4
0
    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
コード例 #5
0
ファイル: library.py プロジェクト: jessedp/tut
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
                    })
コード例 #6
0
 def _airings(self):
     return Api(self.path).airings.get()
コード例 #7
0
 def channel(self):
     channelPath = self.data['airing_details']['channel_path']
     if not self._channel:
         self._channel = Channel(Api(channelPath).getCached())
     return self._channel
コード例 #8
0
 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
コード例 #9
0
 def update(self):
     self.__init__(Api(self.path).get())
コード例 #10
0
 def secondsToEnd(self, start=None):
     start = start or Api.now()
     return compat.timedelta_total_seconds(self.datetimeEnd - start)
コード例 #11
0
 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
コード例 #12
0
 def deleteAll(self, delete_protected=False):
     if delete_protected:
         return Api(self.path)('delete').post()
     else:
         return Api(self.path)('delete').post(filter='unprotected')
コード例 #13
0
 def seasons(self):
     try:
         return Api(self.path).seasons.get()
     except APIError as e:
         logger.error(f'Series.seasons() failed: {format(e.message)}')
         return []
コード例 #14
0
 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
コード例 #15
0
 def secondsToStart(self):
     return compat.timedelta_total_seconds(self.datetime - Api.now())
コード例 #16
0
 def delete(self):
     self.deleted = True
     return Api(self.path).delete()
コード例 #17
0
 def ended(self):
     return self.datetimeEnd < Api.now()
コード例 #18
0
 def airingNow(self, ref=None):
     ref = ref or Api.now()
     return self.datetime <= ref < self.datetimeEnd
コード例 #19
0
 def secondsSinceEnd(self):
     return compat.timedelta_total_seconds(Api.now() - self.datetimeEnd)
コード例 #20
0
 def show(self):
     if not self._show:
         info = Api(self.showPath).get()
         self._show = Show.newFromData(info)
     return self._show
コード例 #21
0
 def episodes(self):
     return Api(self.path).episodes.get()