本文整理汇总了Python中editing.MusicBrainzClient类的典型用法代码示例。如果您正苦于以下问题:Python MusicBrainzClient类的具体用法?Python MusicBrainzClient怎么用?Python MusicBrainzClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MusicBrainzClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: push_data
def push_data():
mb = MusicBrainzClient(cfg.MB_USERNAME, cfg.MB_PASSWORD, cfg.MB_SITE)
for row in aClient.get_mb_data():
gid, workid, iswc, artist, work = row
note = 'Data taken from ' + aClient.search_url(str(workid), 'i')
mb.edit_work(gid, {'iswc': iswc}, note)
print artist + ' work: ' + work + ' Done!'
示例2: main
def main(args):
if not args:
out('Usage: cancel_edits.py <edit_number edit_note>...\n')
out('Example: cancel_edits.py "Edit #123 my mistake"')
out(' cancel_edits.py 123 124 125')
return
edits = []
for arg in args:
if not isinstance(arg, unicode):
arg = unicode(arg, locale.getpreferredencoding())
m = re.match(ur'(?:[Ee]dit )?#?([0-9]+) ?(.*)$', arg)
if not m:
out('invalid edit number "%s", aborting!' % arg)
return
edit_nr = str(m.group(1))
edit_note = m.group(2).lstrip()
edits.append((edit_nr, edit_note))
mb = MusicBrainzClient(cfg.MB_USERNAME, cfg.MB_PASSWORD, cfg.MB_SITE)
for edit_nr, edit_note in edits:
out(u'Cancel edit #%s: %s' % (edit_nr, edit_note if edit_note else u'<no edit note>'))
mb.cancel_edit(str(edit_nr), edit_note)
示例3: MusicBrainzClient
#!/usr/bin/python
import re
import sqlalchemy
from editing import MusicBrainzClient
import time
from utils import out, colored_out, bcolors
import config as cfg
engine = sqlalchemy.create_engine(cfg.MB_DB)
db = engine.connect()
db.execute("SET search_path TO musicbrainz, %s" % cfg.BOT_SCHEMA_DB)
mb = MusicBrainzClient(cfg.MB_USERNAME, cfg.MB_PASSWORD, cfg.MB_SITE)
query = """
SELECT DISTINCT r.id, r.gid AS r_gid, w.gid AS w_gid, r.name, r.comment, lrw.id AS rel_id, lt.id AS link_type, r.artist_credit
FROM recording r
JOIN l_recording_work lrw ON lrw.entity0 = r.id
JOIN link l ON l.id = lrw.link
JOIN link_type lt ON l.link_type = lt.id
JOIN link_attribute la ON la.link = l.id
JOIN link_attribute_type lat ON la.attribute_type = lat.id AND lat.name = 'live'
JOIN work w ON lrw.entity1 = w.id
WHERE r.comment ~ E'live, \\\\d{4}(-\\\\d{2})?(-\\\\d{2})?:'
AND l.begin_date_year IS NULL
AND l.end_date_year IS NULL
AND lt.name = 'performance'
AND r.edits_pending = 0 AND lrw.edits_pending = 0
/* Only one linked work */
AND NOT EXISTS (SELECT 1 FROM l_recording_work lrw2 WHERE lrw2.entity0 = r.id AND lrw2.entity1 <> lrw.entity1)
示例4: MediaWiki
from simplemediawiki import MediaWiki
from editing import MusicBrainzClient
import pprint
import urllib
import time
from utils import mangle_name, join_names, quote_page_title
import config as cfg
engine = sqlalchemy.create_engine(cfg.MB_DB)
db = engine.connect()
db.execute("SET search_path TO musicbrainz, %s" % cfg.BOT_SCHEMA_DB)
wp = MediaWiki("https://en.wikipedia.org/w/api.php")
wps = solr.SolrConnection("http://localhost:8983/solr/wikipedia")
mb = MusicBrainzClient(cfg.MB_USERNAME, cfg.MB_PASSWORD, cfg.MB_SITE)
"""
CREATE TABLE bot_wp_label (
gid uuid NOT NULL,
processed timestamp with time zone DEFAULT now()
);
ALTER TABLE ONLY bot_wp_label
ADD CONSTRAINT bot_wp_label_pkey PRIMARY KEY (gid);
"""
query = """
WITH
labels_wo_wikipedia AS (
示例5: MusicBrainzClient
import re
import sqlalchemy
import solr
from editing import MusicBrainzClient
from mbbot.source.secondhandsongs import SHSWebService
import pprint
import urllib
import time
from utils import mangle_name, join_names, out, colored_out, bcolors
import config as cfg
engine = sqlalchemy.create_engine(cfg.MB_DB)
db = engine.connect()
db.execute("SET search_path TO musicbrainz, %s" % cfg.BOT_SCHEMA_DB)
mb = MusicBrainzClient(cfg.MB_USERNAME, cfg.MB_PASSWORD, cfg.MB_SITE)
shs = SHSWebService()
"""
CREATE TABLE bot_shs_work_lang (
work uuid NOT NULL,
processed timestamp with time zone DEFAULT now(),
CONSTRAINT bot_shs_work_lang_pkey PRIMARY KEY (work)
);
"""
query = """
WITH
works_wo_lang AS (
SELECT w.id AS work_id, u.url AS shs_url
FROM work w
示例6: MediaWiki
from simplemediawiki import MediaWiki
from editing import MusicBrainzClient
import pprint
import urllib
import time
from utils import mangle_name, join_names, out
import config as cfg
engine = sqlalchemy.create_engine(cfg.MB_DB)
db = engine.connect()
db.execute("SET search_path TO musicbrainz")
wp = MediaWiki('http://en.wikipedia.org/w/api.php')
wps = solr.SolrConnection('http://localhost:8983/solr/wikipedia')
mb = MusicBrainzClient(cfg.MB_USERNAME, cfg.MB_PASSWORD, cfg.MB_SITE)
"""
CREATE TABLE bot_wp_rg (
gid uuid NOT NULL,
processed timestamp with time zone DEFAULT now()
);
ALTER TABLE ONLY bot_wp_rg
ADD CONSTRAINT bot_wp_rg_pkey PRIMARY KEY (gid);
"""
query = """
WITH
rgs_wo_wikipedia AS (
SELECT a.id
示例7: MusicBrainzClient
import re
import sqlalchemy
import solr
from editing import MusicBrainzClient
import discogs_client as discogs
import pprint
import urllib
import time
from utils import mangle_name, join_names, out, colored_out, bcolors
import config as cfg
engine = sqlalchemy.create_engine(cfg.MB_DB)
db = engine.connect()
db.execute("SET search_path TO musicbrainz, %s" % cfg.BOT_SCHEMA_DB)
mb = MusicBrainzClient(cfg.MB_USERNAME, cfg.MB_PASSWORD, cfg.MB_SITE)
discogs.user_agent = 'MusicBrainzBot/0.1 +https://github.com/murdos/musicbrainz-bot'
"""
CREATE TABLE bot_discogs_release_packaging (
release uuid NOT NULL,
processed timestamp with time zone DEFAULT now(),
CONSTRAINT bot_discogs_release_packaging_pkey PRIMARY KEY (release)
);
"""
query = """
WITH
releases_wo_packaging AS (
SELECT r.id AS release_id, u.url AS discogs_url
示例8: len
from mbbot.wp.wikipage import WikiPage
from utils import mangle_name, join_names, out, colored_out, bcolors, escape_query, quote_page_title, wp_is_canonical_page
import config as cfg
engine = sqlalchemy.create_engine(cfg.MB_DB)
db = engine.connect()
db.execute("SET search_path TO musicbrainz, %s" % cfg.BOT_SCHEMA_DB)
wp_lang = sys.argv[1] if len(sys.argv) > 1 else 'en'
wp = MediaWiki('https://%s.wikipedia.org/w/api.php' % wp_lang)
suffix = '_' + wp_lang if wp_lang != 'en' else ''
wps = solr.SolrConnection('http://localhost:8983/solr/wikipedia' + suffix)
mb = MusicBrainzClient(cfg.MB_USERNAME, cfg.MB_PASSWORD, cfg.MB_SITE)
"""
CREATE TABLE bot_wp_rg_link (
gid uuid NOT NULL,
lang character varying(2),
processed timestamp with time zone DEFAULT now(),
CONSTRAINT bot_wp_rg_link_pkey PRIMARY KEY (gid, lang)
);
"""
acceptable_countries_for_lang = {
'fr': ['FR', 'MC']
}
acceptable_countries_for_lang['en'] = acceptable_countries_for_lang['fr']
示例9: MusicBrainzClient
import re
import sqlalchemy
import solr
from editing import MusicBrainzClient
import discogs_client
import pprint
import urllib
import time
from utils import mangle_name, join_names, out, colored_out, bcolors
import config as cfg
engine = sqlalchemy.create_engine(cfg.MB_DB)
db = engine.connect()
db.execute("SET search_path TO musicbrainz, %s" % cfg.BOT_SCHEMA_DB)
mb = MusicBrainzClient(cfg.MB_USERNAME, cfg.MB_PASSWORD, cfg.MB_SITE)
discogs = discogs_client.Client('MusicBrainzBot/0.1 +https://github.com/murdos/musicbrainz-bot')
"""
CREATE TABLE bot_discogs_medium_format (
medium integer NOT NULL,
processed timestamp with time zone DEFAULT now(),
CONSTRAINT bot_discogs_medium_format_pkey PRIMARY KEY (medium)
);
"""
query = """
WITH
mediums_with_fuzzy_format AS (
SELECT r.id AS release_id, m.position, m.id AS medium_id, u.url AS discogs_url, m.format
示例10: MusicBrainzClient
#!/usr/bin/python
import re
import sqlalchemy
from editing import MusicBrainzClient
import time
from utils import out, colored_out, bcolors
import config as cfg
engine = sqlalchemy.create_engine(cfg.MB_DB)
db = engine.connect()
db.execute("SET search_path TO musicbrainz, %s" % cfg.BOT_SCHEMA_DB)
mb = MusicBrainzClient(cfg.MB_USERNAME, cfg.MB_PASSWORD, cfg.MB_SITE)
query = """
SELECT DISTINCT r.id, r.gid, r.name, r.comment, lrw.id AS rel_id, lt.id AS link_type, r.artist_credit
FROM recording r
JOIN l_recording_work lrw ON lrw.entity0 = r.id
JOIN link l ON l.id = lrw.link
JOIN link_type lt ON l.link_type = lt.id
JOIN link_attribute la ON la.link = l.id
JOIN link_attribute_type lat ON la.attribute_type = lat.id AND lat.name = 'live'
WHERE r.comment ~ E'live, \\\\d{4}(-\\\\d{2})?(-\\\\d{2})?:'
AND l.begin_date_year IS NULL
AND l.end_date_year IS NULL
AND lt.name = 'performance'
AND r.edits_pending = 0 AND lrw.edits_pending = 0
/* Only one linked work */
AND NOT EXISTS (SELECT 1 FROM l_recording_work lrw2 WHERE lrw2.entity0 = r.id AND lrw2.entity1 <> lrw.entity1)
ORDER BY r.artist_credit
示例11: MediaWiki
from simplemediawiki import MediaWiki
from editing import MusicBrainzClient
import pprint
import urllib
import time
from utils import mangle_name, join_names, mw_remove_markup, out
import config as cfg
engine = sqlalchemy.create_engine(cfg.MB_DB)
db = engine.connect()
db.execute("SET search_path TO musicbrainz")
wp = MediaWiki('http://en.wikipedia.org/w/api.php')
wps = solr.SolrConnection('http://localhost:8983/solr/wikipedia')
mb = MusicBrainzClient(cfg.MB_USERNAME, cfg.MB_PASSWORD, cfg.MB_SITE)
query = """
SELECT DISTINCT
a.id, a.gid, a.name, a.country, a.type, a.gender,
a.begin_date_year,
a.begin_date_month,
a.begin_date_day,
a.end_date_year,
a.end_date_month,
a.end_date_day,
u.url
FROM s_artist a
JOIN l_artist_url l ON l.entity0 = a.id AND l.link IN (SELECT id FROM link WHERE link_type = 179)
JOIN url u ON u.id = l.entity1
LEFT JOIN bot_wp_artist_data b ON a.gid = b.gid
示例12: MusicBrainzClient
import re
import sys
import urllib
import urllib2
import config
import pymongo
import pprint
from editing import MusicBrainzClient
import cgi
mb = MusicBrainzClient('lukz_bot', 'mb', 'http://mb.muziq.eu')
opener = urllib2.build_opener()
if config.WWW_USER_AGENT:
opener.addheaders = [('User-Agent', config.WWW_USER_AGENT)]
mongo = pymongo.Connection()
db = mongo.mbot
html_escape_table = {
"&": "&",
'"': """,
"'": "'",
">": ">",
"<": "<",
}
示例13: isrc_valid
m = re.search(ur'<span property="v:identifier">(.+?)</span>', page)
identifier = m.group(1).upper() if m else None
return identifier if identifier and isrc_valid(identifier) else None
query_releases = '''
SELECT DISTINCT r.id, r.gid, r.barcode
FROM release r
WHERE r.barcode ~ %s
'''
engine = sqlalchemy.create_engine(cfg.MB_DB)
db = engine.connect()
db.execute('SET search_path TO musicbrainz')
zeroinch = ZeroInch()
mb = MusicBrainzClient(cfg.MB_USERNAME, cfg.MB_PASSWORD, cfg.MB_SITE)
ws = MusicBrainzWebservice(cfg.MB_USERNAME, cfg.MB_PASSWORD, cfg.MB_SITE)
def identify_isrc_edit(isrcs):
return lambda edit_nr, text: set(isrcs) == set(re.findall(r'<a href="' + cfg.MB_SITE + r'/isrc/([A-Z0-9]{12})">', text))
isrc_submitted = set(url for url, in db.execute('''SELECT url FROM bot_isrc_zeroinch_submitted'''))
isrc_missing = set(url for url, in db.execute('''SELECT url FROM bot_isrc_zeroinch_missing'''))
isrc_problematic = set(url for url, in db.execute('''SELECT url FROM bot_isrc_zeroinch_problematic'''))
#for artists in [['Gui_Boratto']]:
#for artists in zeroinch.get_artists('/label/Warp_Records'):
for artists in zeroinch.get_artists('/catalogue', cipher='all', page='1'):
for artist in artists:
artist_url = u'http://www.zero-inch.com/artist/%s' % artist
示例14: MusicBrainzClient
import re
import sqlalchemy
import solr
from editing import MusicBrainzClient
import discogs_client as discogs
import pprint
import urllib
import time
from utils import mangle_name, join_names, out, colored_out, bcolors
import config as cfg
engine = sqlalchemy.create_engine(cfg.MB_DB)
db = engine.connect()
db.execute("SET search_path TO musicbrainz, %s" % cfg.BOT_SCHEMA_DB)
mb = MusicBrainzClient(cfg.MB_USERNAME, cfg.MB_PASSWORD, cfg.MB_SITE)
discogs.user_agent = "MusicBrainzBot/0.1 +https://github.com/murdos/musicbrainz-bot"
"""
CREATE TABLE bot_discogs_medium_format (
medium integer NOT NULL,
processed timestamp with time zone DEFAULT now(),
CONSTRAINT bot_discogs_medium_format_pkey PRIMARY KEY (medium)
);
"""
query = """
WITH
mediums_with_fuzzy_format AS (
SELECT r.id AS release_id, m.position, m.id AS medium_id, u.url AS discogs_url, m.format
示例15: MusicBrainzClient
import re
import sqlalchemy
import solr
from editing import MusicBrainzClient
import pprint
import urllib
import time
from utils import mangle_name, join_names, out, colored_out, bcolors
import config as cfg
engine = sqlalchemy.create_engine(cfg.MB_DB)
db = engine.connect()
db.execute("SET search_path TO musicbrainz")
mb = MusicBrainzClient(cfg.MB_USERNAME, cfg.MB_PASSWORD, cfg.MB_SITE)
"""
CREATE TABLE bot_encyclopedisque_medium_format (
gid uuid NOT NULL,
processed timestamp with time zone DEFAULT now()
);
ALTER TABLE ONLY bot_encyclopedisque_medium_format
ADD CONSTRAINT bot_encyclopedisque_medium_format_pkey PRIMARY KEY (gid);
"""
query = """
WITH
releases_wo_7inch AS (