Пример #1
0
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
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()