• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python musicbrainzngs.search_releases函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中musicbrainzngs.search_releases函数的典型用法代码示例。如果您正苦于以下问题:Python search_releases函数的具体用法?Python search_releases怎么用?Python search_releases使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了search_releases函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: match_album

def match_album(artist, album, tracks=None):
    """Searches for a single album ("release" in MusicBrainz parlance)
    and returns an iterator over AlbumInfo objects. May raise a
    MusicBrainzAPIError.

    The query consists of an artist name, an album name, and,
    optionally, a number of tracks on the album.
    """
    # Build search criteria.
    criteria = {'release': album.lower().strip()}
    if artist is not None:
        criteria['artist'] = artist.lower().strip()
    else:
        # Various Artists search.
        criteria['arid'] = VARIOUS_ARTISTS_ID
    if tracks is not None:
        criteria['tracks'] = six.text_type(tracks)

    # Abort if we have no search terms.
    if not any(criteria.values()):
        return

    try:
        res = musicbrainzngs.search_releases(
            limit=config['musicbrainz']['searchlimit'].get(int), **criteria)
    except musicbrainzngs.MusicBrainzError as exc:
        raise MusicBrainzAPIError(exc, 'release search', criteria,
                                  traceback.format_exc())
    for release in res['release-list']:
        # The search result is missing some data (namely, the tracks),
        # so we just use the ID and fetch the rest of the information.
        albuminfo = album_for_id(release['id'])
        if albuminfo is not None:
            yield albuminfo
开发者ID:artemutin,项目名称:beets,代码行数:34,代码来源:mb.py


示例2: getNowTracks

	def getNowTracks(self, albumnumber):
		rx = re.compile('\W');
		ret = []
		res = musicbrainzngs.search_releases(query='Now That\'s What I Call Music ' + str(albumnumber))
		if(not('release-list' in res)):
			return ret
		for release in res['release-list']:
			title = rx.sub('', release['title'].encode('ascii', 'ignore').lower())
			if title != 'nowthatswhaticallmusic' + str(albumnumber):
				continue
			if release['country'] != 'GB':
				continue
			format = 0
			for medium in release['medium-list']:
				if 'format' in medium:
					if medium['format'] == 'CD':
						format = 1
			if format == 1:
				ret.append(release)

		if len(ret) == 1:
			mbid = ret[0]['id']
			return self.getCompilationAlbumTracks(mbid)

		ret = []
		return ret
开发者ID:ads04r,项目名称:MoonShine,代码行数:26,代码来源:moonshine.py


示例3: find_releases

def find_releases(artists_set, year_month):
    good = u""
    questionable = u""

    for artist in artists_set:
        result = musicbrainzngs.search_releases(
            query=u"artist:\"{}\" AND date:{}-?? AND status:official AND primarytype:album".format(artist, year_month))

        if not result['release-list']:
            Logger.debug("no release found for artist %s", artist)

        music_brains_links = u""
        for (idx, rel) in enumerate(result['release-list'], start=1):
            log_album(artist, rel, idx)
            music_brains_links += u'<a href="http://musicbrainz.org/release/{}">{}</a> '\
                .format(rel['id'], rel.get('country', 'NONE'))
            if idx < len(result['release-list']) and rel['title'] == result['release-list'][idx]['title']:
                continue

            album_info = u"<b>{}</b>".format(artist)
            if artist != rel["artist-credit-phrase"]:
                album_info += u"({})".format(rel["artist-credit-phrase"])

            album_info += u" - {} - Released {} in {}<br/>\n".format(rel['title'], rel['date'], music_brains_links)
            music_brains_links = u""
            album_info += u'Links: <a href="https://play.google.com/music/listen#/sr/{0}">Google Music</a> ' \
                          u'<a href="http://www.emusic.com/search/music/?s={0}">eMusic</a> ' \
                          u'<br/><br/>'.format(urllib.quote_plus(rel['title'].encode('utf8')))

            if artist.lower() == rel["artist-credit-phrase"].lower():
                good += album_info
            else:
                questionable += album_info

    return good + questionable
开发者ID:jataro,项目名称:new-music-finder,代码行数:35,代码来源:new_music_finder.py


示例4: match_album

def match_album(artist, album, tracks=None, limit=SEARCH_LIMIT):
    """Searches for a single album ("release" in MusicBrainz parlance)
    and returns an iterator over AlbumInfo objects. May raise a
    MusicBrainzAPIError.

    The query consists of an artist name, an album name, and,
    optionally, a number of tracks on the album.
    """
    # Build search criteria.
    criteria = {"release": album.lower()}
    if artist is not None:
        criteria["artist"] = artist.lower()
    else:
        # Various Artists search.
        criteria["arid"] = VARIOUS_ARTISTS_ID
    if tracks is not None:
        criteria["tracks"] = str(tracks)

    # Abort if we have no search terms.
    if not any(criteria.itervalues()):
        return

    try:
        res = musicbrainzngs.search_releases(limit=limit, **criteria)
    except musicbrainzngs.MusicBrainzError as exc:
        raise MusicBrainzAPIError(exc, "release search", criteria, traceback.format_exc())
    for release in res["release-list"]:
        # The search result is missing some data (namely, the tracks),
        # so we just use the ID and fetch the rest of the information.
        albuminfo = album_for_id(release["id"])
        if albuminfo is not None:
            yield albuminfo
开发者ID:jwyant,项目名称:beets,代码行数:32,代码来源:mb.py


示例5: search_releases

def search_releases(artist, album, limit):
    from lxml import etree

    root = etree.XML(u'<searchreleases></searchreleases>')

    result = musicbrainzngs.search_releases(artist=artist, release=album, country="GB", limit=limit)

    if not result['release-list']:
        etree.SubElement(root, "error").text = "No Releases found"
        log(True, etree.tostring(root, encoding='UTF-8', pretty_print=True, xml_declaration=True))
        sys.exit(1)

    for (idx, release) in enumerate(result['release-list']):
        pprint.pprint(release)
        relNode = etree.SubElement(root, "release")

        etree.SubElement(relNode, "id").text = release['id']
        etree.SubElement(relNode, "ext-score").text = release['ext:score']
        etree.SubElement(relNode, "title").text = release['title']
        etree.SubElement(relNode, "artist-credit-phrase").text = release["artist-credit-phrase"]
        etree.SubElement(relNode, "country").text = release["country"]

        if 'date' in release:
            etree.SubElement(relNode, "date").text = release['date']
            etree.SubElement(relNode, "status").text = release['status']

        if 'release-group' in release:
            etree.SubElement(relNode, "releasegroup").text = release["release-group"]["id"]

    log(True, etree.tostring(root, encoding='UTF-8', pretty_print=True, xml_declaration=True))

    sys.exit(0)
开发者ID:adicarlo,项目名称:mythtv,代码行数:32,代码来源:mbutils.py


示例6: MBReleaseGroup

    def MBReleaseGroup(self):
        """Search for releases on musicbrainz by group ID"""
        rgid = raw_input('Enter release group ID: ')
        results = musicbrainzngs.search_releases(rgid=rgid,
                limit=self.searchResultsLimit)

        if results:
            self.printQueryResults(results)
开发者ID:rlhelinski,项目名称:musicbrainz-catalog,代码行数:8,代码来源:shell.py


示例7: MBReleaseTitle

    def MBReleaseTitle(self):
        """Search for release on musicbrainz by title"""
        title = raw_input('Enter title: ')
        results = musicbrainzngs.search_releases(release=title,
                                                 limit=self.searchResultsLimit)

        if results:
            self.printQueryResults(results)
开发者ID:rlhelinski,项目名称:musicbrainz-catalog,代码行数:8,代码来源:shell.py


示例8: MBReleaseBarcode

    def MBReleaseBarcode(self):
        """Search for release on musicbrainz by barcode"""
        barcode = raw_input('Enter barcode: ')
        results = musicbrainzngs.search_releases(barcode=barcode,
                                                 limit=self.searchResultsLimit)

        if results:
            self.printQueryResults(results)
开发者ID:rlhelinski,项目名称:musicbrainz-catalog,代码行数:8,代码来源:shell.py


示例9: find_releases

def find_releases(name, limit=10, artist_id=None,
                  wanted_keys=('name', 'id', 'title', 'country', 'release-group', 'ext:score', 'asin')):
    with musicbrainz_lock:
        strict = True if artist_id else False
        params = {'release': name, 'arid': artist_id}
        search_results = musicbrainzngs.search_releases(limit=limit, strict=strict, **params)['release-list']
        sorted_by_score = sorted(search_results, cmp=lambda x, y: max(x, y), key=lambda d: int(d['ext:score']))
        return [{k: v for k, v in d.items() if k in wanted_keys} for d in sorted_by_score]
开发者ID:omerbenamram,项目名称:headphones2,代码行数:8,代码来源:musicbrainz.py


示例10: _request

    def _request(query, artist, album=None, track=None):
        results = None
        if track:
            results = musicbrainzngs.search_recordings(query=query)
        elif album:
            results = musicbrainzngs.search_releases(query=query)
        elif artist:
            results = musicbrainzngs.search_artists(query=query)

        return results
开发者ID:FructusCode,项目名称:website,代码行数:10,代码来源:music.py


示例11: MBReleaseCatno

    def MBReleaseCatno(self):
        """Search for release on musicbrainz by catalog number"""
        catno = raw_input('Enter catalog number: ')
        if ' ' in catno:
            _log.warning('Removing whitespaces from string (workaround)')
            catno = catno.replace(' ', '')
        results = musicbrainzngs.search_releases(catno=catno,
                limit=self.searchResultsLimit)

        if results:
            self.printQueryResults(results)
开发者ID:rlhelinski,项目名称:musicbrainz-catalog,代码行数:11,代码来源:shell.py


示例12: artistSearch

def artistSearch(artist):
    if request.method == 'POST':
        artist = request.form['artist']
    if artist == '':
        return redirect(url_for('artistSearch', artist='artistSearch'))
    searched = artist
    result = musicbrainzngs.search_releases(artist=artist, limit=5)
    # relList = result['release-list']
    relList = releaseInfo(result['release-list'])
    return render_template('release_results.html', releases=relList, 
          search_by='artist', searched=searched)
开发者ID:melliss67,项目名称:music-library,代码行数:11,代码来源:application.py


示例13: catnoSearch

def catnoSearch(catno):
    if request.method == 'POST':
        catno = request.form['catno']
    if catno == '':
        return redirect(url_for('catnoSearch', catno='catnoSearch'))
    searched = catno
    result = musicbrainzngs.search_releases(catno=catno, limit=5)
    # relList = result['release-list']
    relList = releaseInfo(result['release-list'])
    return render_template('release_results.html', releases=relList, 
          search_by='catno', searched=searched)
开发者ID:melliss67,项目名称:music-library,代码行数:11,代码来源:application.py


示例14: barcodeSearch

def barcodeSearch(barcode):
    if request.method == 'POST':
        barcode = request.form['barcode']
    if barcode == '':
        return redirect(url_for('barcodeSearch', barcode='barcodeSearch'))
    searched = barcode
    result = musicbrainzngs.search_releases(barcode=barcode, limit=5)
    # relList = result['release-list']
    relList = releaseInfo(result['release-list'])
    return render_template('release_results.html', releases=relList, 
          search_by='barcode', searched=searched)
开发者ID:melliss67,项目名称:music-library,代码行数:11,代码来源:application.py


示例15: searchMusicBrainzAlbumAndArtist

def searchMusicBrainzAlbumAndArtist(artist, album):
	"""searchMusicBrainzByID looks for a release ID by an album and an artist"""
	result = musicbrainzngs.search_releases(artist=artist, release=album)
	results = []
	if not result['release-list']:
		return results
	for release in result['release-list']:
		
		# If we haven't seen this id yet, add it to the return list
		if release.get('id') not in results:
			results.append(release.get('id'))
	return results
开发者ID:samskeller,项目名称:greymatterreview,代码行数:12,代码来源:main.py


示例16: search_releases

def search_releases(artist, album, quality):
  attempt = 0;
  while attempt < maxAttempt:
    try:
      result = MB.search_releases(artist=artist, release=album, quality=quality);# Attempt to get release information
    except:
      attempt+=1;                                                               # Increment the attempt counter by one
      time.sleep(2);                                                            # Sleep 2 seconds
    else:  
      break;  
  if attempt == maxAttempt: return None;                                         # If MusicBrainz search fails three times, return 2
  return result;  
开发者ID:kwodzicki,项目名称:iTunes_Music_Converter,代码行数:12,代码来源:get_album_art.py


示例17: get_releases

def get_releases(artist_id, release_group_id):

	records = dict()
	result = musicbrainzngs.search_releases(arid=artist_id,rgid=release_group_id,strict=True)

	for release in result['release-list']:

		release_name = release['title']
		release_mbid = release['id']
		records.update({release_mbid: release_name})

	return records
开发者ID:Sacknuss,项目名称:trollectoR,代码行数:12,代码来源:metadata.py


示例18: MusicBrainz

def MusicBrainz(release_path, query, ofile):
    try:
        r = musicbrainzngs.search_releases(query.replace('-', ''))
        id = r['release-list'][0]['id']
        img = musicbrainzngs.get_image_list(id)
        url = img['images'][0]['image']
        urllib.urlretrieve(url, ofile)
        print("OK " + ofile)
        return query, ofile
    except Exception as e:
        print("Error for %s (%s)" % (release_path, e))
        traceback.print_exc()
        return genimage(release_path, query, ofile)
开发者ID:scampion,项目名称:pdfmp3,代码行数:13,代码来源:app.py


示例19: getSongs

def getSongs(whatGroup):
  mbAlbum = mb.search_releases(
    artistname=mbquote(whatGroup['artist']),
   release= mbquote(whatGroup['groupName']), 
    limit=1)['release-list']
  return [
    (x['recording']['title'],
      int(float(
        x['recording']['length'] if 'length' in x['recording'] 
        else (x['track_or_recording_length'] if 'track_or_recording_length' in x 
        else x['length'] if 'length' in x else 0)
      )/1000.))
    for tracklist in 
      mb.get_release_by_id(
        mbAlbum[0]['id'],
        includes=['recordings'])['release']['medium-list']
    for x in tracklist['track-list']]
开发者ID:aristeia,项目名称:zarvox,代码行数:17,代码来源:libzarv.py


示例20: searchMusicBrainzAlbumsByArtist

def searchMusicBrainzAlbumsByArtist(artist):
	"""searchMusicBrainzAlbumsByArtists takes an artist name as a string and returns a list of album
	titles by the given artist."""

	result = musicbrainzngs.search_releases(artist=artist, limit=15)
	
	results = []
	if not result['release-list']:
		return results
	for release in result['release-list']:
		# Grab just the name of the artist
		resultArtist = release['artist-credit-phrase']
		
		# Make sure the artist is the one we were searching for and if so, add the album title
		if resultArtist == artist and release['title'] not in results:
			results.append(release['title'])
	return results
开发者ID:keagon3,项目名称:greymatterreview,代码行数:17,代码来源:main.py



注:本文中的musicbrainzngs.search_releases函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python musicbrainzngs.set_hostname函数代码示例发布时间:2022-05-27
下一篇:
Python musicbrainzngs.search_recordings函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap