本文整理汇总了Python中musicbrainzngs.set_hostname函数的典型用法代码示例。如果您正苦于以下问题:Python set_hostname函数的具体用法?Python set_hostname怎么用?Python set_hostname使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_hostname函数的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: __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
示例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: 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
开发者ID:JoeLametta,项目名称:whipper,代码行数:53,代码来源:main.py
示例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
开发者ID:noam09,项目名称:headphones,代码行数:50,代码来源:mb.py
示例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')
开发者ID:MediaKraken,项目名称:MediaKraken_Deployment,代码行数:14,代码来源:common_metadata_musicbrainz.py
示例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
开发者ID:bennieb79,项目名称:headphones,代码行数:40,代码来源:mb.py
示例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()
开发者ID:precabal,项目名称:musiclopedia,代码行数:24,代码来源:retrieveArtist.py
示例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
}
开发者ID:AnneGilles,项目名称:c3sbrainz,代码行数:24,代码来源:views.py
示例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
开发者ID:EQ4,项目名称:pycompmusic,代码行数:31,代码来源:stats.py
示例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 \
开发者ID:tonyhong272,项目名称:MusicML,代码行数:31,代码来源:recordingSearch.py
示例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("'","'\"'\"'")
开发者ID:aristeia,项目名称:zarvox,代码行数:30,代码来源:libzarv.py
示例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):
开发者ID:imclab,项目名称:pycompmusic,代码行数:31,代码来源:musicbrainz.py
示例16: main
import logging
logger = logging.getLogger(__name__)
def main():
# set user agent
musicbrainzngs.set_useragent("whipper", whipper.__version__,
"https://github.com/JoeLametta/whipper")
try:
server = config.Config().get_musicbrainz_server()
except KeyError, e:
sys.stderr.write('whipper: %s\n' % e.message)
sys.exit()
musicbrainzngs.set_hostname(server)
# register plugins with pkg_resources
distributions, _ = pkg_resources.working_set.find_plugins(
pkg_resources.Environment([directory.data_path('plugins')])
)
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, e:
sys.stderr.write('whipper: error: %s\n' % e)
if (type(e) is common.EjectError and
cmd.options.eject in ('failure', 'always')):
eject_device(e.device)
return 255
except RuntimeError, e:
开发者ID:RecursiveForest,项目名称:whipper,代码行数:31,代码来源:main.py
示例17: create_app
def create_app():
app = Flask(__name__)
# Configuration
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), ".."))
import config
app.config.from_object(config)
# Logging
from webserver.loggers import init_loggers
init_loggers(app)
# Database connection
from db import init_db_engine
init_db_engine(app.config['SQLALCHEMY_DATABASE_URI'])
# Memcached
if 'MEMCACHED_SERVERS' in app.config:
from db import cache
cache.init(app.config['MEMCACHED_SERVERS'],
app.config['MEMCACHED_NAMESPACE'],
debug=1 if app.debug else 0)
# Extensions
from flask_uuid import FlaskUUID
FlaskUUID(app)
# MusicBrainz
import musicbrainzngs
from db import SCHEMA_VERSION
musicbrainzngs.set_useragent(app.config['MUSICBRAINZ_USERAGENT'], SCHEMA_VERSION)
if app.config['MUSICBRAINZ_HOSTNAME']:
musicbrainzngs.set_hostname(app.config['MUSICBRAINZ_HOSTNAME'])
# OAuth
from webserver.login import login_manager, provider
login_manager.init_app(app)
provider.init(app.config['MUSICBRAINZ_CLIENT_ID'],
app.config['MUSICBRAINZ_CLIENT_SECRET'])
# Error handling
from webserver.errors import init_error_handlers
init_error_handlers(app)
# Template utilities
app.jinja_env.add_extension('jinja2.ext.do')
from webserver import utils
app.jinja_env.filters['date'] = utils.reformat_date
app.jinja_env.filters['datetime'] = utils.reformat_datetime
# Blueprints
from webserver.views.index import index_bp
from webserver.views.data import data_bp
from webserver.views.api import api_bp
from webserver.views.stats import stats_bp
from webserver.views.login import login_bp
from webserver.views.user import user_bp
from webserver.views.datasets import datasets_bp
app.register_blueprint(index_bp)
app.register_blueprint(data_bp)
app.register_blueprint(api_bp)
app.register_blueprint(stats_bp)
app.register_blueprint(login_bp, url_prefix='/login')
app.register_blueprint(user_bp, url_prefix='/user')
app.register_blueprint(datasets_bp, url_prefix='/datasets')
return app
开发者ID:EQ4,项目名称:acousticbrainz-server,代码行数:67,代码来源:__init__.py
示例18: callme
try:
conn = psycopg2.connect(config.PG_CONNECT)
conn2 = psycopg2.connect(config.PG_CONNECT)
except psycopg2.OperationalError as err:
print "Cannot connect to database: %s" % err
sys.exit(-1)
mbdata = ""
def callme(data):
global mbdata
mbdata = data
musicbrainzngs.set_useragent(config.USER_AGENT_STRING, config.USER_AGENT_VERSION, config.USER_AGENT_USER)
musicbrainzngs.set_format(fmt='json')
musicbrainzngs.set_parser(callme)
musicbrainzngs.set_hostname("musicbrainz.org")
#musicbrainzngs.set_hostname("musicb-1.us.archive.org:5060")
#musicbrainzngs.set_rate_limit(False)
offset = 0
while True:
cur = conn.cursor()
cur.execute("""SELECT mbid
FROM match
WHERE mbid IS NOT NULL
AND mb_data IS NULL
OFFSET %s
LIMIT %s""", (offset, NUM_ROWS))
# if cur.rowcount == 0:
# break
开发者ID:mayhem,项目名称:ia_matcher,代码行数:31,代码来源:get_mbdata.py
示例19: get_symbtrmu2
# 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):
# Get symbtrmu2 file and extract makam, form and usul
开发者ID:felipebetancur,项目名称:pycompmusic,代码行数:31,代码来源:update_mb_works.py
示例20: init
def init(app_name, app_version, hostname=None):
# We need to identify our application to access the MusicBrainz webservice.
# See https://python-musicbrainzngs.readthedocs.org/en/latest/usage/#identification for more info.
musicbrainzngs.set_useragent(app_name, app_version)
if hostname:
musicbrainzngs.set_hostname(hostname)
开发者ID:metabrainz,项目名称:critiquebrainz,代码行数:6,代码来源:musicbrainz.py
注:本文中的musicbrainzngs.set_hostname函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论