Ejemplo n.º 1
0
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!'
Ejemplo n.º 2
0
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!'
        shs_work = shs.lookup_work(int(m.group(1)))
    else:
        continue
        
    if 'language' in shs_work:
        work = dict(work)
        shs_lang = shs_work['language']
        
        if shs_lang not in SHS_MB_LANG_MAPPING:
            colored_out(bcolors.FAIL, ' * No mapping defined for language ''%s' % shs_lang)
        else:
            work['iswcs'] = []
            for (iswc,) in db.execute(iswcs_query, work['id']):
                work['iswcs'].append(iswc)
            work['language'] = SHS_MB_LANG_MAPPING[shs_lang]
            update = ('language',)

            colored_out(bcolors.HEADER, ' * using %s, found language: %s' % (work['shs_url'], shs_lang))
            edit_note = 'Setting work language from attached SecondHandSongs link (%s)' % work['shs_url']
            out(' * edit note: %s' % (edit_note,))

            mb.edit_work(work, update, edit_note)
        
    else:
        colored_out(bcolors.NONE, ' * using %s, no language has been found' % (work['shs_url'],))

    if work['processed'] is None:
        db.execute("INSERT INTO bot_shs_work_lang (work) VALUES (%s)", (work['gid'],))
    else:
        db.execute("UPDATE bot_shs_work_lang SET processed = now() WHERE work = %s", (work['gid'],))
Ejemplo n.º 4
0
            colored_out(bcolors.FAIL, ' * No mapping defined for language '
                        '%s' % shs_lang)
        else:
            work['iswcs'] = []
            for (iswc, ) in db.execute(iswcs_query, work['id']):
                work['iswcs'].append(iswc)
            work['language'] = SHS_MB_LANG_MAPPING[shs_lang]
            update = ('language', )

            colored_out(
                bcolors.HEADER, ' * using %s, found language: %s' %
                (work['shs_url'], shs_lang))
            edit_note = 'Setting work language from attached SecondHandSongs link (%s)' % work[
                'shs_url']
            out(' * edit note: %s' % (edit_note, ))

            mb.edit_work(work, update, edit_note)

    else:
        colored_out(
            bcolors.NONE,
            ' * using %s, no language has been found' % (work['shs_url'], ))

    if work['processed'] is None:
        db.execute("INSERT INTO bot_shs_work_lang (work) VALUES (%s)",
                   (work['gid'], ))
    else:
        db.execute(
            "UPDATE bot_shs_work_lang SET processed = now() WHERE work = %s",
            (work['gid'], ))