本文整理汇总了Python中musicbrainzngs.set_hostname函数的典型用法代码示例。如果您正苦于以下问题:Python set_hostname函数的具体用法?Python set_hostname怎么用?Python set_hostname使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_hostname函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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)
)
示例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)
示例4: __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)
示例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),
)
示例6: main
def main():
server = config.Config().get_musicbrainz_server()
musicbrainzngs.set_hostname(server)
# Find whipper's plugins paths (local paths have higher priority)
plugins_p = [directory.data_path('plugins')] # local path (in $HOME)
if hasattr(sys, 'real_prefix'): # no getsitepackages() in virtualenv
plugins_p.append(
get_python_lib(plat_specific=False, standard_lib=False,
prefix='/usr/local') + '/whipper/plugins')
plugins_p.append(get_python_lib(plat_specific=False,
standard_lib=False) + '/whipper/plugins')
else:
plugins_p += [x + '/whipper/plugins' for x in site.getsitepackages()]
# register plugins with pkg_resources
distributions, _ = pkg_resources.working_set.find_plugins(
pkg_resources.Environment(plugins_p)
)
list(map(pkg_resources.working_set.add, distributions))
try:
cmd = Whipper(sys.argv[1:], os.path.basename(sys.argv[0]), None)
ret = cmd.do()
except SystemError as e:
logger.critical("SystemError: %s", e)
if (isinstance(e, common.EjectError) and
cmd.options.eject in ('failure', 'always')):
eject_device(e.device)
return 255
except RuntimeError as e:
print(e)
return 1
except KeyboardInterrupt:
return 2
except ImportError as e:
raise
except task.TaskException as e:
if isinstance(e.exception, ImportError):
raise ImportError(e.exception)
elif isinstance(e.exception, common.MissingDependencyException):
logger.critical('missing dependency "%s"', e.exception.dependency)
return 255
if isinstance(e.exception, common.EmptyError):
logger.debug("EmptyError: %s", e.exception)
logger.critical('could not create encoded file')
return 255
# in python3 we can instead do `raise e.exception` as that would show
# the exception's original context
logger.critical(e.exceptionMessage)
return 255
return ret if ret else 0
示例7: 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
示例8: __init__
def __init__(self, option_config_json):
# If you plan to submit data, authenticate
# musicbrainzngs.auth(option_config_json.get('MediaBrainz','User').strip(),
# option_config_json.get('MediaBrainz','Password').strip())
musicbrainzngs.set_useragent("MediaKraken_Server", common_version.APP_VERSION,
"[email protected] "
"https://https://github.com/MediaKraken/MediaKraken_Deployment")
# If you are connecting to a development server
if option_config_json['MusicBrainz']['Host'] is not None:
if option_config_json['MusicBrainz']['Host'] != 'Docker':
musicbrainzngs.set_hostname(option_config_json['MusicBrainz']['Host'] + ':'
+ option_config_json['MusicBrainz']['Port'])
else:
musicbrainzngs.set_hostname('mkmusicbrainz:5000')
示例9: 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
示例10: main
def main(*argv):
m.set_useragent("applicatiason", "0.201", "http://recabal.com")
m.set_hostname("localhost:8080")
m.auth("vm", "musicbrainz")
f = open(sys.argv[1],'r')
for line in f.xreadlines():
line = line.strip();
lifeSpanString = "false,false"
art_dict = m.search_artists(artist=line,limit=1,strict=True,tag="jazz")
if art_dict['artist-count']!=0:
lifeSpanString = getLifeSpan(art_dict)
else:
art_dict = m.search_artists(artist=line,limit=1,strict=True)
if art_dict['artist-count']!=0:
lifeSpanString = getLifeSpan(art_dict)
print line+","+lifeSpanString
f.close()
示例11: status_view
def status_view(request):
bar = 25
output = ''
hostname = '192.168.54.101:5000'
musicbrainzngs.set_hostname(hostname)
musicbrainzngs.auth("user", "password")
musicbrainzngs.set_useragent(
'c3sbrainz',
'0.1a',
'[email protected]'
)
artistid = "952a4205-023d-4235-897c-6fdb6f58dfaa"
#import pdb
#pdb.set_trace()
print(dir(musicbrainzngs))
#output = dir(musicbrainzngs)
output = musicbrainzngs.get_artist_by_id(artistid)
print musicbrainzngs.get_artist_by_id(artistid)
return {
'foo': 'foo',
'bar': bar,
'hostname': hostname,
'output': output
}
示例12: Stats
#
# 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()
# releases
示例13: similar
$ ./recordingSearch.py "the beatles" revolver
Revolver, by The Beatles
Released 1966-08-08 (Official)
MusicBrainz ID: b4b04cbf-118a-3944-9545-38a0a88ff1a2
"""
import musicbrainzngs
import sys
import difflib
musicbrainzngs.set_useragent(
"python-musicbrainzngs-example",
"0.1",
"https://github.com/alastair/python-musicbrainzngs/",
)
musicbrainzngs.set_hostname("localhost:5000")
def similar(seq1, seq2):
return difflib.SequenceMatcher(a=seq1.lower(), b=seq2.lower()).ratio()
def fetch_recording(artist, title, **kwarg):
"""fetch recording from musicBrainz
"""
result = musicbrainzngs.search_recordings(query='', limit=10, offset=None, strict=False, artist = artist, release = title)
seq2 =' '.join([title, artist])
high_score = 0
idx = 0
for i in range(0,10):
seq1 = ' '.join([result['recording-list'][i]['title'], result['recording-list'][i]['artist-credit-phrase']])
similarity_score = similar(seq1,seq2)
if similarity_score > high_score and 'instrumental' not in seq1 and (not 'disambiguation' in result['recording-list'][i] or \
示例14: len
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 '!':
newText = newText.strip(badchar)
return newText.strip()
def bashEscape(s):
return s.replace("'","'\"'\"'")
示例15: ws_ids
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# 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/
from log import log
import urllib2
import xml.etree.ElementTree as etree
import musicbrainzngs as mb
mb.set_useragent("Dunya", "0.1")
mb.set_rate_limit(False)
mb.set_hostname("musicbrainz.s.upf.edu")
MUSICBRAINZ_COLLECTION_CARNATIC = ""
MUSICBRAINZ_COLLECTION_HINDUSTANI = ""
MUSICBRAINZ_COLLECTION_MAKAM = ""
def ws_ids(xml):
ids = []
tree = etree.fromstring(xml)
count = int(list(list(tree)[0])[2].attrib["count"])
for rel in list(list(list(tree)[0])[2]):
ids.append(rel.attrib["id"])
return (count, ids)
def get_releases_in_collection(collection):