Exemplo n.º 1
0
 def _item_info_for(self, item):
     info = dict(item_source=self,
                 source_type='sharing',
                 feed_id=item.feed_id,
                 feed_name=None,
                 feed_url=None,
                 state=u'saved',
                 release_date=item.get_release_date(),
                 size=item.size,
                 duration=item.duration,
                 resume_time=0,
                 permalink=item.permalink,
                 commentslink=item.comments_link,
                 payment_link=item.payment_link,
                 has_shareable_url=bool(item.url),
                 can_be_saved=False,
                 pending_manual_dl=False,
                 pending_auto_dl=False,
                 expiration_date=None,
                 item_viewed=True,
                 downloaded=True,
                 is_external=False,
                 video_watched=True,
                 video_path=item.get_filename(),
                 thumbnail=item.get_thumbnail(),
                 thumbnail_url=item.thumbnail_url or u'',
                 file_format=item.file_format,
                 license=item.license,
                 file_url=item.url or u'',
                 is_container_item=False,
                 is_file_item=False,
                 is_playable=True,
                 children=[],
                 file_type=item.file_type,
                 subtitle_encoding=item.subtitle_encoding,
                 seeding_status=None,
                 media_type_checked=True,
                 mime_type=item.enclosure_type,
                 artist=item.artist,
                 auto_rating=None,
                 date_added=item.get_creation_time(),
                 last_played=item.get_creation_time(),
                 download_info=None,
                 device=None,
                 remote=True,
                 leechers=None,
                 seeders=None,
                 up_rate=None,
                 down_rate=None,
                 up_total=None,
                 down_total=None,
                 up_down_ratio=0,
                 play_count=0,
                 skip_count=0,
                 host=item.host,
                 port=item.port,
                 is_playing=False)
     info.update(item.get_iteminfo_metadata())
     return messages.ItemInfo(item.id, **info)
Exemplo n.º 2
0
    def set_is_playing(self, info, is_playing):
        """
        Mark the given ItemInfo as playing, based on the is_playing bool.
        Should also send a 'changed' message, if the is_playing state changed.

        Sharing items don't have a real database to back them up so just use
        a back pointer to the item source and emit a 'changed' message.
        """
        if info.is_playing != is_playing:
            # modifying the ItemInfo in-place messes up the Tracker's
            # object-changed logic, so make a copy
            info = messages.ItemInfo(info.id, **info.__dict__)
            info.is_playing = is_playing
            info.item_source.emit("changed", info)
Exemplo n.º 3
0
 def set_is_playing(self, info, is_playing):
     """
     Mark the given ItemInfo as playing, based on the is_playing bool.
     Should also send a 'changed' message, if the is_playing state changed.
     """
     if info.is_playing != is_playing:
         # modifying the ItemInfo in-place messes up the Tracker's
         # object-changed logic, so make a copy
         info_cache = app.device_manager.info_cache[info.device_info.mount]
         info = info_cache[info.id] = messages.ItemInfo(
             info.id, **info.__dict__)
         database = info.device_info.database
         info.is_playing = is_playing
         database[info.file_type][info.id][u'is_playing'] = is_playing
         database.emit('item-changed', info)
Exemplo n.º 4
0
    def _item_info_for(item):
        info = {
            'feed_id': item.feed_id,
            'feed_name': item.get_source(),
            'feed_url': item.get_feed_url(),
            'state': item.get_state(),
            'release_date': item.get_release_date(),
            'size': item.get_size(),
            'duration': item.get_duration_value(),
            'resume_time': item.resumeTime,
            'permalink': item.get_link(),
            'commentslink': item.get_comments_link(),
            'payment_link': item.get_payment_link(),
            'has_shareable_url': item.has_shareable_url(),
            'can_be_saved': item.show_save_button(),
            'pending_manual_dl': item.is_pending_manual_download(),
            'pending_auto_dl': item.is_pending_auto_download(),
            'item_viewed': item.get_viewed(),
            'downloaded': item.is_downloaded(),
            'is_external': item.is_external(),
            'video_watched': item.get_seen(),
            'video_path': item.get_filename(),
            'thumbnail': item.get_thumbnail(),
            'thumbnail_url': item.get_thumbnail_url(),
            'file_format': item.get_format(),
            'license': item.get_license(),
            'file_url': item.get_url(),
            'is_container_item': item.isContainerItem,
            'is_file_item': item.is_file_item,
            'is_playable': item.is_playable(),
            'file_type': item.file_type,
            'subtitle_encoding': item.subtitle_encoding,
            'media_type_checked': item.media_type_checked,
            'seeding_status': item.torrent_seeding_status(),
            'mime_type': item.enclosure_type,
            'date_added': item.get_creation_time(),
            'last_played': item.get_watched_time(),
            'last_watched': item.lastWatched,
            'downloaded_time': item.downloadedTime,
            'children': [],
            'expiration_date': None,
            'download_info': None,
            'leechers': None,
            'seeders': None,
            'up_rate': None,
            'down_rate': None,
            'up_total': None,
            'down_total': None,
            'up_down_ratio': 0.0,
            'remote': False,
            'device': None,
            'source_type': 'database',
            'play_count': item.play_count,
            'skip_count': item.skip_count,
            'auto_rating': item.get_auto_rating(),
            'is_playing': item.is_playing(),
        }
        info.update(item.get_iteminfo_metadata())
        if item.isContainerItem:
            info['children'] = [
                DatabaseItemSource._item_info_for(i)
                for i in item.get_children()
            ]
        if not item.keep and not item.is_external():
            info['expiration_date'] = item.get_expiration_time()

        if item.downloader:
            info['download_info'] = messages.DownloadInfo(item.downloader)
        elif info['state'] == 'downloading':
            info['download_info'] = messages.PendingDownloadInfo()

        ## Torrent-specific stuff
        if item.looks_like_torrent() and hasattr(item.downloader, 'status'):
            status = item.downloader.status
            if item.is_transferring():
                # gettorrentdetails only
                info['leechers'] = status.get('leechers', 0)
                info['seeders'] = status.get('seeders', 0)
                info['connections'] = status.get('connections', 0)
                info['up_rate'] = status.get('upRate', 0)
                info['down_rate'] = status.get('rate', 0)

            # gettorrentdetailsfinished & gettorrentdetails
            info['up_total'] = status.get('uploaded', 0)
            info['down_total'] = status.get('currentSize', 0)
            if info['down_total'] > 0:
                info['up_down_ratio'] = (float(info['up_total']) /
                                         info['down_total'])

        return messages.ItemInfo(item.id, **info)
Exemplo n.º 5
0
 def _item_info_for(self, item):
     if item.duration is None:
         duration = None
     else:
         duration = item.duration / 1000
     info = dict(source_type='device',
                 name=item.get_title(),
                 feed_id=item.feed_id,
                 feed_name=(item.feed_name is None and item.feed_name
                            or self.device.name),
                 parent_sort_key=None,
                 feed_url=item.feed_url,
                 state=u'saved',
                 description=u'',
                 release_date=item.get_release_date(),
                 size=item.size,
                 duration=duration,
                 resume_time=0,
                 permalink=item.permalink,
                 commentslink=item.comments_link,
                 payment_link=item.payment_link,
                 has_shareable_url=(item.url
                                    and not item.url.startswith('file://')),
                 can_be_saved=False,
                 pending_manual_dl=False,
                 pending_auto_dl=False,
                 expiration_date=None,
                 item_viewed=True,
                 downloaded=True,
                 is_external=False,
                 video_watched=True,
                 video_path=item.get_filename(),
                 thumbnail=item.get_thumbnail(),
                 thumbnail_url=item.thumbnail_url or u'',
                 file_format=item.file_format,
                 license=item.license,
                 file_url=item.url or u'',
                 is_container_item=False,
                 is_file_item=False,
                 is_playable=True,
                 children=[],
                 file_type=item.file_type,
                 subtitle_encoding=item.subtitle_encoding,
                 seeding_status=None,
                 mime_type=item.enclosure_type,
                 artist=item.artist,
                 date_added=item.get_creation_time(),
                 last_played=item.get_creation_time(),
                 download_info=None,
                 device=item.device,
                 remote=False,
                 leechers=None,
                 seeders=None,
                 up_rate=None,
                 down_rate=None,
                 up_total=None,
                 down_total=None,
                 up_down_ratio=0,
                 play_count=0,
                 skip_count=0,
                 auto_rating=0,
                 is_playing=item.is_playing)
     _add_metadata(info, item)
     return messages.ItemInfo(item.id, **info)