本文整理汇总了Python中musicbrainzngs.set_rate_limit函数的典型用法代码示例。如果您正苦于以下问题:Python set_rate_limit函数的具体用法?Python set_rate_limit怎么用?Python set_rate_limit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_rate_limit函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self):
log = logging.getLogger('util.importer.Importer.__init__')
musicbrainzngs.set_useragent("NRG Processor", "0.01", "http://anorg.net/")
musicbrainzngs.set_rate_limit(MUSICBRAINZ_RATE_LIMIT)
if MUSICBRAINZ_HOST:
musicbrainzngs.set_hostname(MUSICBRAINZ_HOST)
开发者ID:hzlf,项目名称:openbroadcast,代码行数:8,代码来源:__old_importer.py
示例2: configure
def configure():
"""Set up the python-musicbrainz-ngs module according to settings
from the beets configuration. This should be called at startup.
"""
musicbrainzngs.set_hostname(config["musicbrainz"]["host"].get(unicode))
musicbrainzngs.set_rate_limit(
config["musicbrainz"]["ratelimit_interval"].as_number(), config["musicbrainz"]["ratelimit"].get(int)
)
开发者ID:jwyant,项目名称:beets,代码行数:8,代码来源:mb.py
示例3: __init__
def __init__(self):
musicbrainzngs.set_useragent("NRG Processor", "0.01", "http://anorg.net/")
musicbrainzngs.set_rate_limit(MUSICBRAINZ_RATE_LIMIT)
self.file_metadata = None
if MUSICBRAINZ_HOST:
musicbrainzngs.set_hostname(MUSICBRAINZ_HOST)
开发者ID:hzlf,项目名称:openbroadcast.org,代码行数:9,代码来源:identifier.py
示例4: turn_off_musicbrainz_rate_limiting_if_cassette_exists
def turn_off_musicbrainz_rate_limiting_if_cassette_exists(cassette_name):
# if cassettes exist, turn off rate limiting
cassette = os.path.join(CASSETTE_LIBRARY_DIR, cassette_name)
if os.path.exists(cassette):
logger.info('Cassettes directory existsing, turning off rate-limiting')
musicbrainzngs.set_rate_limit(False)
else:
musicbrainzngs.set_rate_limit()
logger.warn("Couldn't find cassettes, going to hit real musicbrainz API")
开发者ID:omerbenamram,项目名称:headphones2,代码行数:9,代码来源:conftest.py
示例5: configure
def configure():
"""Set up the python-musicbrainz-ngs module according to settings
from the beets configuration. This should be called at startup.
"""
hostname = config['musicbrainz']['host'].as_str()
musicbrainzngs.set_hostname(hostname)
musicbrainzngs.set_rate_limit(
config['musicbrainz']['ratelimit_interval'].as_number(),
config['musicbrainz']['ratelimit'].get(int),
)
开发者ID:artemutin,项目名称:beets,代码行数:10,代码来源:mb.py
示例6: setUp
def setUp(self):
musicbrainzngs.set_rate_limit(3, 3)
self.cop = Timecop()
self.cop.install()
@musicbrainz._rate_limit
def limited():
pass
self.func = limited
开发者ID:imclab,项目名称:python-musicbrainz-ngs,代码行数:10,代码来源:test_requests.py
示例7: __init__
def __init__(self):
musicbrainzngs.set_useragent("NRG Processor", "0.01", "http://anorg.net/")
musicbrainzngs.set_rate_limit(MUSICBRAINZ_RATE_LIMIT)
self.pp = pprint.PrettyPrinter(indent=4)
self.pp.pprint = lambda d: None
if MUSICBRAINZ_HOST:
musicbrainzngs.set_hostname(MUSICBRAINZ_HOST)
开发者ID:alainwolf,项目名称:openbroadcast.org,代码行数:10,代码来源:process.py
示例8: test_invalid_args
def test_invalid_args(self):
""" Passing invalid arguments to set_rate_limit should throw
an exception """
try:
musicbrainzngs.set_rate_limit(1, 0)
self.fail("Required exception wasn't raised")
except ValueError as e:
self.assertTrue("new_requests" in str(e))
try:
musicbrainzngs.set_rate_limit(0, 1)
self.fail("Required exception wasn't raised")
except ValueError as e:
self.assertTrue("limit_or_interval" in str(e))
try:
musicbrainzngs.set_rate_limit(1, -1)
self.fail("Required exception wasn't raised")
except ValueError as e:
self.assertTrue("new_requests" in str(e))
try:
musicbrainzngs.set_rate_limit(0, -1)
self.fail("Required exception wasn't raised")
except ValueError as e:
self.assertTrue("limit_or_interval" in str(e))
开发者ID:imclab,项目名称:python-musicbrainz-ngs,代码行数:26,代码来源:test_requests.py
示例9: startmb
def startmb():
mbuser = None
mbpass = None
if headphones.CONFIG.MIRROR == "musicbrainz.org":
mbhost = "musicbrainz.org"
mbport = 80
sleepytime = 1
elif headphones.CONFIG.MIRROR == "custom":
mbhost = headphones.CONFIG.CUSTOMHOST
mbport = int(headphones.CONFIG.CUSTOMPORT)
mbuser = headphones.CONFIG.CUSTOMUSER
mbpass = headphones.CONFIG.CUSTOMPASS
sleepytime = int(headphones.CONFIG.CUSTOMSLEEP)
elif headphones.CONFIG.MIRROR == "headphones":
mbhost = "musicbrainz.codeshy.com"
mbport = 80
mbuser = headphones.CONFIG.HPUSER
mbpass = headphones.CONFIG.HPPASS
sleepytime = 0
else:
return False
musicbrainzngs.set_useragent("headphones", "0.0", "https://github.com/rembo10/headphones")
musicbrainzngs.set_hostname(mbhost + ":" + str(mbport))
# Their rate limiting should be redundant to our lock
if sleepytime == 0:
musicbrainzngs.set_rate_limit(False)
else:
# calling it with an it ends up blocking all requests after the first
musicbrainzngs.set_rate_limit(limit_or_interval=float(sleepytime))
mb_lock.minimum_delta = sleepytime
# Add headphones credentials
if headphones.CONFIG.MIRROR == "headphones" or headphones.CONFIG.CUSTOMAUTH:
if not mbuser or not mbpass:
logger.warn("No username or password set for MusicBrainz server")
else:
musicbrainzngs.hpauth(mbuser, mbpass)
# Let us know if we disable custom authentication
if not headphones.CONFIG.CUSTOMAUTH and headphones.CONFIG.MIRROR == "custom":
musicbrainzngs.disable_hpauth()
logger.debug(
"Using the following server values: MBHost: %s, MBPort: %i, Sleep Interval: %i", mbhost, mbport, sleepytime
)
return True
开发者ID:noam09,项目名称:headphones,代码行数:50,代码来源:mb.py
示例10: main
def main():
parser = IrankOptionParser()
parser.add_option('--threshold', default=5, type='int', help='include only artists with at least THRESHOLD files in collection')
parser.add_option('--target', type='int', help='update only TARGET artists and then exit')
parser.add_option('--max-age', metavar='DAYS', type='int', help='if --target is given, also update all artists which haven\'t been updated in DAYS days')
parser.add_option('--min-age', metavar='DAYS', type='int', help='if --target is given, ignore artists which have been checked within DAYS days')
parser.add_option('--update-only', help='don\'t print RSS feed', action='store_true')
parser.add_option('--full', help='wipe existing DB', action='store_true')
parser.add_option('--quick', help='don\'t update DB if it already exists', action='store_true')
options, args = parser.parse_args()
logging.basicConfig(level=logging.DEBUG if options.verbose else logging.WARN)
app = IrankApp(options)
mb_path = os.path.join(app.base_path, 'musicbrainz.sqlite')
if options.full:
try:
os.unlink(mb_path)
except OSError as e:
if e.errno != errno.ENOENT: raise
existing = os.path.exists(mb_path)
mbdb = (load_db if existing else init_db)(mb_path)
version = irank.version()
mb.set_useragent("irank", version, "https://github.com/gfxmonk/python-irank")
logging.debug("setting rate limit to 2/s")
mb.set_rate_limit(new_requests = 2)
try:
if not (existing and options.quick):
db = irank_db.load(app.db_path)
populate_db(mbdb, options, db)
db.close()
if not options.update_only:
releases = mbdb.execute('''select
artist, title, date
from releases
order by date desc
limit 100''')
doc = make_feed(releases)
print(doc.toprettyxml())
finally:
mbdb.close()
开发者ID:timbertson,项目名称:app-customisations,代码行数:43,代码来源:irank-releases.py
示例11: startmb
def startmb():
mbuser = None
mbpass = None
if headphones.MIRROR == "musicbrainz.org":
mbhost = "musicbrainz.org"
mbport = 80
sleepytime = 1
elif headphones.MIRROR == "custom":
mbhost = headphones.CUSTOMHOST
mbport = int(headphones.CUSTOMPORT)
sleepytime = int(headphones.CUSTOMSLEEP)
elif headphones.MIRROR == "headphones":
mbhost = "144.76.94.239"
mbport = 8181
mbuser = headphones.HPUSER
mbpass = headphones.HPPASS
sleepytime = 0
else:
return False
musicbrainzngs.set_useragent("headphones","0.0","https://github.com/rembo10/headphones")
musicbrainzngs.set_hostname(mbhost + ":" + str(mbport))
if sleepytime == 0:
musicbrainzngs.set_rate_limit(False)
else:
#calling it with an it ends up blocking all requests after the first
musicbrainzngs.set_rate_limit(limit_or_interval=float(sleepytime))
# Add headphones credentials
if headphones.MIRROR == "headphones":
if not mbuser and mbpass:
logger.warn("No username or password set for VIP server")
else:
musicbrainzngs.hpauth(mbuser,mbpass)
logger.debug('Using the following server values: MBHost: %s, MBPort: %i, Sleep Interval: %i', mbhost, mbport, sleepytime)
return True
开发者ID:bennieb79,项目名称:headphones,代码行数:40,代码来源:mb.py
示例12: find_releases
import mutagen
from mutagen.easyid3 import EasyID3
from mutagen.easymp4 import EasyMP4
from mutagen.oggvorbis import OggVorbis
from mutagen.flac import FLAC
from optparse import OptionParser
import os
import smtplib
import urllib
musicbrainzngs.set_useragent(
"new_music_finder.py",
"0.2",
"https://joetotaro.net",
)
musicbrainzngs.set_rate_limit(limit_or_interval=1.0, new_requests=1)
FORMAT = '%(asctime)s %(levelname)s %(funcName)s:%(lineno)d %(message)s'
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""
开发者ID:jataro,项目名称:new-music-finder,代码行数:31,代码来源:new_music_finder.py
示例13: get_symbtrmu2
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see http://www.gnu.org/licenses/
import urllib2
import urllib
import json
import cookielib
import re
import sys
import compmusic
import musicbrainzngs as mb
mb.set_useragent("Dunya", "0.1")
mb.set_rate_limit(True)
mb.set_hostname("musicbrainz.org")
domain = "https://musicbrainz.org"
password = '####'
username = '####'
login_url = '/login'
work_url = '/work/%s/edit'
auth_token = "###"
symbtrmu2_url = 'http://dunya.compmusic.upf.edu/document/by-id/%s/symbtrmu2'
dunya_fuzzy_url = 'http://dunya.compmusic.upf.edu/api/makam/fuzzy'
mb_cache = {}
def get_symbtrmu2(work_mbid):
开发者ID:felipebetancur,项目名称:pycompmusic,代码行数:31,代码来源:update_mb_works.py
示例14: Stats
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see http://www.gnu.org/licenses/
import sys
import os
import argparse
import collections
import compmusic.file
import compmusic.musicbrainz
import musicbrainzngs as mb
mb.set_useragent("Dunya", "0.1")
mb.set_rate_limit(False)
mb.set_hostname("sitar.s.upf.edu:8090")
import eyed3
import logging
eyed3.utils.log.log.setLevel(logging.ERROR)
class Stats(object):
# How many recordings are done for each work
# key is workid
work_recording_counts = collections.Counter()
# artists. could be artists of the release, or as release
# rels, or as track rels
artists = set()
开发者ID:EQ4,项目名称:pycompmusic,代码行数:31,代码来源:stats.py
示例15: set_up_musicbrainzngs
def set_up_musicbrainzngs( user_agent_app, user_agent_version ):
"""
Call this before running `mp3_tag_fixer.py`
"""
musicbrainzngs.set_useragent( user_agent_app, user_agent_version )
musicbrainzngs.set_rate_limit( limit_or_interval=1.0, new_requests=1 )
开发者ID:dezzroy,项目名称:music-tagger,代码行数:6,代码来源:online_resources.py
示例16: print
# print("Error: cannot ping "+sites[args[0]]+"\n")
# exit(1)
#if len(args)>1:
# pingtest(args[1:])
def concat3D(list1,list2):
if len(list1)==len(list2):
return [ list1[x]+list2[x] for x in xrange(list1)]
print("Error: cannot add two lists who differ in length")
return []
def getConfig():
return getFileContents('config')
config = getConfig()
mb.set_rate_limit()
mb.set_useragent('Zarvox_Automated_DJ','Alpha',"KUPS' [email protected]")
mbMultiplier = float(config['musicbrainz_multiplier'])
if 'musicbrainz_hostname' in config:
mbHostname = config['musicbrainz_hostname']
print("Setting musicbrainz hostname to "+mbHostname)
mb.set_hostname(mbHostname)
def whatquote(text):
return text.replace('+','%2B')
def mbquote(text):
newText = text
for badchar in '()[]^@/~=&"':
newText = newText.replace(badchar, ' ')
for badchar in '!':
开发者ID:aristeia,项目名称:zarvox,代码行数:31,代码来源:libzarv.py
示例17: MusicbrainzLock
print_function, unicode_literals)
import sys
import logbook
import musicbrainzngs
from beets.autotag.mb import album_info
from headphones2 import local_redis
from redis.lock import Lock
from retry import retry
RELEASE_INCLUDES = ['media', 'recordings', 'release-groups', 'labels', 'artist-credits']
musicbrainzngs.set_useragent("headphones2", "0.0", "https://github.com/omerbenamram/headphones2")
musicbrainzngs.set_hostname("musicbrainz.org:80")
musicbrainzngs.set_rate_limit()
logger = logbook.Logger(__name__)
logger.handlers.append(logbook.StreamHandler(sys.stdout))
class MusicbrainzLock(Lock):
def __enter__(self):
super(MusicbrainzLock, self).__enter__()
logger.debug('MusicbrainzLock acquired')
def __exit__(self, exc_type, exc_val, exc_tb):
super(MusicbrainzLock, self).__exit__(exc_type, exc_val, exc_tb)
logger.debug('MusicbrainzLock released')
musicbrainz_lock = MusicbrainzLock(local_redis, 'musicbrainz', thread_local=False)
开发者ID:omerbenamram,项目名称:headphones2,代码行数:31,代码来源:musicbrainz.py
示例18: setUp
def setUp(self):
musicbrainzngs.set_useragent("a", "1")
musicbrainzngs.set_rate_limit(1, 100)
urllib2.build_opener = self.build_opener
开发者ID:krbaker,项目名称:python-musicbrainz-ngs,代码行数:4,代码来源:test_mbxml_search.py
示例19: get_album_art
def get_album_art(artist, album, file,
year = None, lang = None, tracks = None, quality = None, format = None,
status = None, verbose = False):
'''
Name:
get_album_art
Purpose:
A function to download album artwork using the musicbrainz api
Inputs:
artist : The artist of the album
album : Name of the album
file : Full path to where the file will be downloaded
Outputs:
Downloads album artwork
Keywords:
year : Year album was released
tracks : The number of tracks on the album. Default is None.
lang : The language of the release. Default is english (eng)
quality : Quality of the returned info. Default is high.
format : Format of the release (cd, vinyl, etc.). Default is CD.
status : The type of release. Default is official.
Author and History:
Kyle R. Wodzicki Created 24 May 2016
Adapted from examples int he musicbrainzngs package.
Modified 12 Nov. 2016 by Kyle R. Wodzicki
Changed the data['artist'] == artist.upper() to
data['artist'] in artist.upper(). This should allow a little more
flexibility. One example is the Riding with the King album by B.B. King
and Eric Clapton. However, musicbrainz has the artist as just B.B. King.
Issues may arise if the name of an artist somehow fits into the name
of the artist of interest.
'''
MB.set_useragent("iTunes_Convert_KRW", "1.0"); # Set the user of the MusicBrainz API
MB.set_rate_limit(limit_or_interval=False); # Set the limit interval to false, i.e., no limit
open(file, 'a').close(); # Empty file created so do not attempt to download on subsequent runs. THIS FILE IS OVERWRITTEN IF ARTWORK FOUND!!!!
quality = 'high' if quality is None else quality;
status = 'official' if status is None else status;
lang = 'eng' if lang is None else lang;
format = 'CD' if format is None else format;
release_id = None; # Set release_id to None
result = search_releases(artist, album, quality);
if result is None: return 2
for i in range(-1,len(importance)):
if (i >= 0): exec(importance[i] + " = None"); # Set a given 'importance' variable to None.
for release in result['release-list']: # Iterate over list of releases
data = parse_release( release ); # Parse the release
if data is None: continue; # If vital information not present in release, the skip
if (verbose is True): print( data ); # Print data IF verbose
if (data['artist'] in artist.upper() or artist.upper() in data['artist']):
if (data['album'] not in album.upper() and \
album.upper() not in data['album']): continue;
if (status is not None):
if (data['status'] != status.upper()): continue; # If status exists and does NOT match the default status, skip
if (data['disambig'] is not None):
if (data['disambig'] not in album.upper()): continue;
if (format is not None):
if (format.upper() != data['format']): continue; # If user input format for the album and that does not match the number on the release, skip
if (tracks is not None):
if (int(tracks) != data['tracks']): continue; # If user input number of tracks and that does not match the number on the release, skip
if (year is not None):
if (int(year) != data['year']): continue; # If user input year and that does not match the year of the release, skip
if (lang is not None):
if (lang.upper() != data['lang']): continue; # If user input year and that does not match the year of the release, skip
release_id = release['id']; # Get the MusicBrainz ID for the album
release_info = get_release_by_id( release_id ); # Get information about the relase
if release_info is None: return 3; # If MusicBrainz search fails three times, return 2
if (verbose is True): print( release_info );
if get_image(release_info, release_id, file):
return 0;
return 1
开发者ID:kwodzicki,项目名称:iTunes_Music_Converter,代码行数:73,代码来源:get_album_art.py
示例20: findRelease
def findRelease(self):
name = self.query
results = []
limit = 1
chars = set('!?*')
if any((c in chars) for c in name):
name = '"'+name+'"'
mb.set_useragent("headphones","1.0","https://github.com/erikvip/headphones")
mb.set_rate_limit(True)
res = mb.search_releases(query='artist:'+name,limit=limit)
logging.info('musicbrainz query: %s' % name)
logging.info('musicbrainz response: \n %s' % res)
for a in res['release-list']:
album = {
'id': a['id'],
'artist': a['artist-credit-phrase'],
#'date': a['date'],
#'country': a['country'],
'status': a['status'],
'title' : a['title'],
'tracks' : []
}
disc = mb.get_release_by_id(a['id'], ["media","recordings"])
output = "TITLE \"%(artist)s - %(title)s\"\n" % album
output += "PERFORMER \"%(artist)s\"\n" % album
output += "FILE \"%s.mp3l\" MP3\n" % a['id']
time = 0
minutes = 0
seconds = 0
logging.info('musicbrainz release response: \n %s' % disc)
for d in disc['release']['medium-list']:
for t in d['track-list']:
track = {
'position': str(t['position'].zfill(2)),
'title' : t['recording']['title'].encode('ascii', 'ignore'),
'minutes' : str(minutes).zfill(2),
'seconds ': seconds,
'duration' : "%s:%s" % (str(minutes).zfill(2), seconds),
'seconds' : time
}
output += " TRACK %(position)s AUDIO\n" % track
output += " TITLE \"%(title)s\"\n" % track
# if t['position'] == "1":
# output += " INDEX 00 00:00:00\n"
output += " INDEX 01 %(duration)s:00\n" % track
# Convert recording time to Minutes:Seconds
time += int(t['length']) / 1000
minutes = time/60
seconds = str(time%60)[:2].zfill(2)
# logging.info('Track #%(position)s \tDuration: %(duration)s [%(seconds)ss] \t%(title)s' % track)
results.append(album)
#return results
return output
开发者ID:erikvip,项目名称:ytAlbumSplit,代码行数:74,代码来源:ytAlbumSplit.py
注:本文中的musicbrainzngs.set_rate_limit函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论