コード例 #1
0
 def setup_tracker(self):
     # Set up our item tracker
     query = itemtrack.SharingItemTrackerQuery()
     query.add_condition('file_type', '=', u'audio')
     query.set_order_by(['title'])
     item_source = item.SharingItemSource(self.share.info)
     self.tracker = itemtrack.ItemTracker(self.idle_scheduler, query,
                                          item_source)
コード例 #2
0
 def test_playlist_filter(self):
     self.client.add_playlist(
         testobjects.make_mock_daap_playlist(3001, 'playlist'))
     self.client.set_playlist_items(3001, [1001, 1002])
     self.run_client_update()
     query = itemtrack.SharingItemTrackerQuery()
     query.add_condition('sharing_item_playlist_map.playlist_id', '=', 3001)
     query.set_order_by(['title'])
     self.tracker.change_query(query)
     self.check_list(self.video1, self.video2)
     # test changes
     self.client.set_playlist_items(3001, [1001, 1002, 2001])
     self.run_client_update()
     self.process_items_changed_messages()
     self.check_list(self.audio1, self.video1, self.video2)
コード例 #3
0
ファイル: itemlist.py プロジェクト: nicolasembleton/miro
    def _make_base_query(self, tab_type, tab_id):
        if self.is_for_device():
            query = itemtrack.DeviceItemTrackerQuery()
        elif self.is_for_share():
            query = itemtrack.SharingItemTrackerQuery()
        else:
            query = itemtrack.ItemTrackerQuery()

        if tab_type == 'videos':
            query.add_condition('file_type', '=', 'video')
        elif tab_type == 'music':
            query.add_condition('file_type', '=', 'audio')
        elif tab_type == 'others':
            query.add_condition('file_type', '=', 'other')
        elif tab_type == 'search':
            query.add_condition('feed.orig_url', '=', 'dtv:search')
        elif tab_type == 'downloading':
            # FIXME: this should also include failed downloads from the manual
            # feed
            sql = ("remote_downloader.state IN ('downloading', 'uploading', "
                   "'paused', 'uploading-paused', 'offline')")
            query.add_complex_condition('remote_downloader.state', sql, ())
        elif tab_type == 'feed':
            query.add_condition('feed_id', '=', tab_id)
        elif tab_type == 'feed-folder' and tab_id == 'feed-base-tab':
            # all feeds tab
            query.add_condition('feed.orig_url', 'IS NOT', None)
            query.add_condition('feed.orig_url', '!=', 'dtv:manualFeed')
            query.add_condition('feed.orig_url', 'NOT LIKE', 'dtv:search%')
        elif tab_type == 'feed-folder':
            # NOTE: this also depends on the folder_id column of feed, but we
            # don't track that in any way.  If that changed while the user was
            # viewing the display, then they wouldn't see the changes.
            # However, the only way for this to change is drag and drop, so we
            # can ignore this.
            sql = ("feed_id in "
                   "(SELECT feed.id FROM feed WHERE feed.folder_id=?)")
            query.add_complex_condition('feed_id', sql, (tab_id, ))
        elif tab_type == 'folder-contents':
            query.add_condition('parent_id', '=', tab_id)
        elif tab_type == 'device-video':
            query.add_condition('file_type', '=', u'video')
        elif tab_type == 'device-audio':
            query.add_condition('file_type', '=', u'audio')
        elif tab_type == 'sharing' and tab_id.startswith("sharing-"):
            # browsing a playlist on a share
            id_components = tab_id.split("-")
            if len(id_components) == 2:
                # browsing an entire share, no filters needed
                pass
            else:
                # browsing a playlist
                playlist_id = id_components[-1]
                if playlist_id == 'audio':
                    query.add_condition('file_type', '=', u'audio')
                elif playlist_id == 'video':
                    query.add_condition('file_type', '=', u'video')
                elif playlist_id == 'podcast':
                    query.add_condition(
                        'sharing_item_playlist_map.playlist_id', '=',
                        u'podcast')
                elif playlist_id == 'playlist':
                    query.add_condition(
                        'sharing_item_playlist_map.playlist_id', '=',
                        u'playlist')
                else:
                    query.add_condition(
                        'sharing_item_playlist_map.playlist_id', '=',
                        int(playlist_id))

        elif tab_type == 'sharing':
            # browsing an entire share, we don't need any filters on the query
            pass
        elif tab_type == 'manual':
            # for the manual tab, tab_id is a list of ids to play
            id_list = tab_id
            placeholders = ",".join("?" for i in xrange(len(id_list)))
            sql = "item.id IN (%s)" % placeholders
            query.add_complex_condition('item.id', sql, id_list)
        else:
            raise ValueError("Can't handle tab (%r, %r)" % (tab_type, tab_id))
        return query