コード例 #1
0
    def load_similar_tracks(self, file_):
        """Perform search using existing metadata information
        from the file as query."""
        self.retry_params = Retry(self.load_similar_tracks, file_)
        self.file_ = file_
        metadata = file_.orig_metadata
        query = {
                'track': metadata['title'],
                'artist': metadata['artist'],
                'release': metadata['album'],
                'tnum': metadata['tracknumber'],
                'tracks': metadata['totaltracks'],
                'qdur': string_(metadata.length // 2000),
                'isrc': metadata['isrc'],
        }

        # Generate query to be displayed to the user (in search box).
        # If advanced query syntax setting is enabled by user, display query in
        # advanced syntax style. Otherwise display only track title.
        if config.setting["use_adv_search_syntax"]:
            query_str = ' '.join(['%s:(%s)' % (item, escape_lucene_query(value))
                                  for item, value in query.items() if value])
        else:
            query_str = query["track"]

        query["limit"] = QUERY_LIMIT
        self.search_box.search_edit.setText(query_str)
        self.show_progress()
        self.tagger.xmlws.find_tracks(
                self.handle_reply,
                **query)
コード例 #2
0
    def show_similar_albums(self, cluster):
        """Perform search by using existing metadata information
        from the cluster as query."""
        self.retry_params = Retry(self.show_similar_albums, cluster)
        self.cluster = cluster
        metadata = cluster.metadata
        query = {
            "artist": metadata["albumartist"],
            "release": metadata["album"],
            "tracks": string_(len(cluster.files))
        }

        # Generate query to be displayed to the user (in search box).
        # If advanced query syntax setting is enabled by user, display query in
        # advanced syntax style. Otherwise display only album title.
        if config.setting["use_adv_search_syntax"]:
            query_str = ' '.join(['%s:(%s)' % (item, escape_lucene_query(value))
                                for item, value in query.items() if value])
        else:
            query_str = query["release"]

        query["limit"] = QUERY_LIMIT
        self.search_box.search_edit.setText(query_str)
        self.show_progress()
        self.tagger.xmlws.find_releases(
            self.handle_reply,
            **query)
コード例 #3
0
ファイル: searchdialog.py プロジェクト: ctsanders1/picard
    def load_similar_tracks(self, file_):
        """Performs search by using existing metadata information
        from the file."""

        self.retry_params = Retry(self.load_similar_tracks, file_)
        self.file_ = file_
        metadata = file_.orig_metadata
        query = {
                'track': metadata['title'],
                'artist': metadata['artist'],
                'release': metadata['album'],
                'tnum': metadata['tracknumber'],
                'tracks': metadata['totaltracks'],
                'qdur': str(metadata.length / 2000),
                'isrc': metadata['isrc'],
        }
        if config.setting["use_adv_search_syntax"]:
            # Display the query in advance syntax format.
            query_str = ' '.join(['%s:(%s)' % (item, escape_lucene_query(value))
                                  for item, value in query.iteritems() if value])
        else:
            # Display only the track title
            query_str = query["track"]
        # `query_str` is used only for presenting purpose. Actual query consists of all filters and follows
        # advanced query syntax.
        query["limit"] = 25
        self.search_box.search_edit.setText(query_str)
        self.show_progress()
        self.tagger.xmlws.find_tracks(
                self.handle_reply,
                **query)