Beispiel #1
0
 def do_pause(self, line):
     """pause <name> -- Pauses a download by name."""
     if self.selection_type is None:
         print "Error: No feed/playlist selected."
         return
     item = self._find_item(line)
     if item is None:
         print "No item named %r" % line
         return
     if item.get_state() == "downloading":
         item.pause()
     else:
         print "%s is not being downloaded" % item.get_title()
Beispiel #2
0
 def do_resume(self, line):
     """resume <name> -- Resumes a download by name."""
     if self.selection_type is None:
         print "Error: No feed/playlist selected."
         return
     item = self._find_item(line)
     if item is None:
         print "No item named %r" % line
         return
     if item.get_state() == "paused":
         item.resume()
     else:
         print "%s is not a paused download" % item.get_title()
Beispiel #3
0
 def do_stop(self, line):
     """stop <name> -- Stops download by name."""
     if self.selection_type is None:
         print "Error: No feed/playlist selected."
         return
     item = self._find_item(line)
     if item is None:
         print "No item named %r" % line
         return
     if item.get_state() in ("downloading", "paused"):
         item.expire()
     else:
         print "%s is not being downloaded" % item.get_title()
Beispiel #4
0
 def do_resume(self, line):
     """resume <name> -- Resumes a download by name."""
     if self.selection_type is None:
         print "Error: No feed/playlist selected."
         return
     item = self._find_item(line)
     if item is None:
         print "No item named %r" % line
         return
     if item.get_state() == 'paused':
         item.resume()
     else:
         print '%s is not a paused download' % item.get_title()
Beispiel #5
0
 def do_pause(self, line):
     """pause <name> -- Pauses a download by name."""
     if self.selection_type is None:
         print "Error: No feed/playlist selected."
         return
     item = self._find_item(line)
     if item is None:
         print "No item named %r" % line
         return
     if item.get_state() == 'downloading':
         item.pause()
     else:
         print '%s is not being downloaded' % item.get_title()
Beispiel #6
0
 def do_stop(self, line):
     """stop <name> -- Stops download by name."""
     if self.selection_type is None:
         print "Error: No feed/playlist selected."
         return
     item = self._find_item(line)
     if item is None:
         print "No item named %r" % line
         return
     if item.get_state() in ('downloading', 'paused'):
         item.expire()
     else:
         print '%s is not being downloaded' % item.get_title()
Beispiel #7
0
 def do_download(self, line):
     """download <name> -- Downloads an item by name in the feed/playlist selected."""
     if self.selection_type is None:
         print "Error: No feed/playlist selected."
         return
     item = self._find_item(line)
     if item is None:
         print "No item named %r" % line
         return
     if item.get_state() == "downloading":
         print "%s is currently being downloaded" % item.get_title()
     elif item.is_downloaded():
         print "%s is already downloaded" % item.get_title()
     else:
         item.download()
Beispiel #8
0
 def printout_item_list(self, *views):
     totalItems = 0
     for view in views:
         totalItems += view.count()
     if totalItems > 0:
         print "%-20s %-10s %s" % ("State", "Size", "Name")
         print "-" * 70
         for view in views:
             for item in view:
                 state = item.get_state()
                 if state == "downloading":
                     state += " (%0.0f%%)" % item.download_progress()
                 print "%-20s %-10s %s" % (state, item.get_size_for_display(), item.get_title())
         print
     else:
         print "No items"
Beispiel #9
0
 def do_download(self, line):
     """download <name> -- Downloads an item by name in the feed/playlist
     selected.
     """
     if self.selection_type is None:
         print "Error: No feed/playlist selected."
         return
     item = self._find_item(line)
     if item is None:
         print "No item named %r" % line
         return
     if item.get_state() == 'downloading':
         print '%s is currently being downloaded' % item.get_title()
     elif item.is_downloaded():
         print '%s is already downloaded' % item.get_title()
     else:
         item.download()
Beispiel #10
0
 def printout_item_list(self, *views):
     totalItems = 0
     for view in views:
         totalItems += view.count()
     if totalItems > 0:
         print "%-20s %-10s %s" % ("State", "Size", "Name")
         print "-" * 70
         for view in views:
             for item in view:
                 state = item.get_state()
                 if state == 'downloading':
                     state += ' (%0.0f%%)' % item.download_progress()
                 print "%-20s %-10s %s" % (
                     state, item.get_size_for_display(), item.get_title())
         print
     else:
         print "No items"
Beispiel #11
0
    def _item_info_for(item):
        info = {
            'name': item.get_title(),
            'feed_id': item.feed_id,
            'feed_name': item.parent_title,
            'parent_sort_key': item.get_parent_sort_key(),
            'feed_url': item.get_feed_url(),
            'state': item.get_state(),
            'description': item.get_description(),
            'release_date': item.get_release_date(),
            'size': item.get_size(),
            'duration': item.get_duration_value(),
            'resume_time': item.resume_time,
            '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': not item.new,
            'downloaded': item.is_downloaded(),
            'is_external': item.is_external(),
            'video_watched': item.get_watched(),
            '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.is_container_item,
            'is_file_item': item.is_file_item,
            'is_playable': item.is_playable(),
            'file_type': item.file_type,
            'subtitle_encoding': item.subtitle_encoding,
            '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.last_watched,
            'downloaded_time': item.downloaded_time,
            '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(),
            }
        _add_metadata(info, item)
        if item.is_container_item:
            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 item.downloader is not None:
            dler = item.downloader
            if item.is_transferring():
                # gettorrentdetails only
                info['leechers'] = dler.leechers
                info['seeders'] = dler.seeders
                info['connections'] = dler.connections
                info['up_rate'] = dler.upload_rate
                info['down_rate'] = dler.rate

            # gettorrentdetailsfinished & gettorrentdetails
            info['up_total'] = dler.upload_size
            info['down_total'] = dler.current_size
            if info['down_total'] > 0:
                info['up_down_ratio'] = (float(info['up_total']) /
                                              info['down_total'])

        return messages.ItemInfo(item.id, **info)
Beispiel #12
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)