⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 audio.py

📁 Yahoo!search API. 用于搜索引擎接口
💻 PY
📖 第 1 页 / 共 2 页
字号:
        Track          - The track number on the album.        ClickUrl       - The URL for linking to the audio file.    The following attributes are optional, and might not be set:        Thumbnail      - The URL of a thumbnail picture of the album cover.    Thumbnail is in turn another dictionary, which will have the following    keys:        Url             - URL of the thumbnail.        Height          - Height of the thumbnail, in pixels (optional).        Width           - Width of the thumbnail, in pixels (optional).    The two attributes Artist and RelatedAlbums are both lists of dicts,    with the keys:        Name            - Textual "name" value.        Id              - Unique identifier (internal yahoo ID).    Example:        results = ws.parse_results()        for res in results:            print "%s - %s bytes" % (res.Artist.Name, res.Title)    """    def _init_res_fields(self):        """Initialize the valid result fields."""        self._res_fields = [('Title', None, None),                            ('Publisher', None, None),                            ('Length', None, int),                            ('ReleaseDate', None, None),                            ('Track', None, int),                            ('ClickUrl', "", None),                            ]    def _parse_result(self, result):        """Internal method to parse one Result node"""        res = super(SongSearch, self)._parse_result(result)        node = result.getElementsByTagName('Thumbnail')        if node:            res['Thumbnail'] = self._tags_to_dict(node[0], (('Url', None, None),                                                            ('Height', 0, int),                                                            ('Width', 0, int)),                                                  parse_id=False)        else:            res['Thumbnail'] = None        node = result.getElementsByTagName('Artist')        if node:            res['Artist'] = self._id_attribute_to_dict(node[0])        else:            res['Artist'] = None        node = result.getElementsByTagName('Album')        if node:            res['Album'] = self._id_attribute_to_dict(node[0])        else:            res['Album'] = None        return res## Song Download Location DOM parser#class SongDownloadLocation(dom.DOMResultParser):    """SongDownloadLocation - DOM parser for Song Download Location    Each result is a dictionary populated with the extracted data from the    XML results. The following keys are always available:        Source        - The source provider for the file.        Url           - The url for accessing the file.        Format        - The format the file has been encoded in.    The following attributes are optional, and might not be set:        Price         - The price, in dollars, of the song.        Length        - The length of the song in seconds.        Channels      - The number of channels. Usually 1 (mono) or                        2 (stereo).        Restrictions  - A space-separated list of restrictions:                          * drm denotes files with some form of digital                            rights management.                          * subrequired means a subscription to the                            appropriate service is required.                          * subnotrequired means a subscription to the                            appropriate service is not required.                          * win denotes files that will play on Windows.                          * mac denotes files that will play on Macintosh.                          * copyokay means this file may be copied.                          * copynotokay means this file may not be copied.                          * cdokay means this file may be burned to CD.        Quality       - A quality metric for files found on the web. Values                        range from 1 (worst) to 5 (best).    Example:        results = ws.parse_results()        for res in results:            print "%s - %s bytes" % (res.Name, res.YahooMusicPage)    """    def _init_res_fields(self):        """Initialize the valid result fields."""        super(SongDownloadLocation, self)._init_res_fields()        self._res_fields = [('Source', None, None),                            ('Url', None, None),                            ('Format', None, None),                            ('Price', 0.0, float),                            ('Length', 0, int),                            ('Channels', "", None),                            ('Restrictions', "", None),                            ('Quality', 0, int),                            ]## Podcast Search DOM parser#class PodcastSearch(dom.DOMResultParser):    """PodcastSearch - DOM parser for Podcast Search    Each result is a dictionary populated with the extracted data from the    XML results. The following keys are always available:        Title            - The title of the audio file.        Summary          - Summary text associated with the audio file.        Url              - The URL for the audio file or stream.        ClickUrl         - The URL for linking to the audio file.        RefererUrl       - The URL of the web page hosting the content.        FileSize         - The size of the file, in bytes.        FileFormat       - One of aiff, midi, mp3, msmedia, quicktime,                           realmedia, wav or other.        Duration         - The duration of the audio file in seconds.        Streaming        - Whether the audio file is streaming or not.    The following attributes are optional, and might not be set:        SampleSize       - The number of bits used in sampling the sound.        Channels         - The number of channels in the audio. Usually                           1 (mono) or 2 (stereo).        Publisher        - The creator of the video file.        Restrictions     - Provides any restrictions for this media                           object. Restrictions include noframe and                           noinline. See developer site for more info.        Copyright        - The copyright owner.    If present, the Thumbnail value is in turn another dictionary, which will    have these keys:        Url             - URL of the thumbnail.        Height          - Height of the thumbnail in pixels (optional).        Width           - Width of the thumbnail in pixels (optional).    Example:        results = ws.parse_results(dom)        for res in results:            print "%s - %s bytes" % (res.Title, res.FileSize)    """    def _init_res_fields(self):        """Initialize the valid result fields."""        super(PodcastSearch, self)._init_res_fields()        self._res_fields.extend((('RefererUrl', None, None),                                 ('FileSize', None, int),                                 ('FileFormat', None, None),                                 ('Streaming', None, parser.string_to_bool),                                 ('Duration', None, float),                                 ('SampleSize', 0, int),                                 ('Channels', "", None),                                 ('Publisher', "", None),                                 ('Restrictions', "", None),                                 ('Copyright', "", None)))    def _parse_result(self, result):        """Internal method to parse one Result node"""        res = super(PodcastSearch, self)._parse_result(result)        node = result.getElementsByTagName('Thumbnail')        if node:            res['Thumbnail'] = self._tags_to_dict(node[0], (('Url', None, None),                                                            ('Height', 0, int),                                                            ('Width', 0, int)))        else:            res['Thumbnail'] = None        return res## local variables:# mode: python# indent-tabs-mode: nil# py-indent-offset: 4# end:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -