Ejemplo n.º 1
0
def dlmain(week, dlf, *args):

    """Parse song list file and pass on to dlloop

    filename is name of song list file.
    dlf is dl function to use.
    args is passed directly to dlloop().

    dlmain() also handles some personal defaults.  In particular:
    Comment fields are set to id if blank.
    apic are set to 'smile' if blank.

    """

    print('Loading song list...')
    slist = dm.get_songlist(week)
    if isinstance(slist, songlist.RankedSongList):
        print('Translate song list first')
        raise ExitException(1)
    # personal defaults here
    for entry in slist:
        if entry.comment == '':
            entry.comment = entry.id
        if entry.apic == '':
            entry.apic = 'smile'
    print('Downloading...')
    dlloop(dlf, slist, dm.get_songlist_path(week), *args)
    print('Marking song list as done...')
    slist.done = True
    slist.save()
    print('Done.')
Ejemplo n.º 2
0
def show_main(week, raw=False):
    if week is None:
        for x in dm.check_songlists():
            x = dm.get_songlist(x)
            print_summary(x)
    else:
        path = dm.get_songlist_path(week)
        if not os.path.isfile(path):
            raise StructureError('{} is not a file.'.format(path))
        if raw:
            with open(path) as f:
                for line in f:
                    print(line, end="")
        else:
            x = dm.get_songlist(week)
            print_summary(x)
            for entry in x:
                print('-' * 10)
                print(
"""ID:{}
Name:{}
Artist:{}
Album:{}
Comment:{}
APIC:{}""".format(*iter(entry)))
Ejemplo n.º 3
0
def add_main(week, file):
    try:
        slist = parse.read_list(file, ranks=True)
    except (StructureError, FileFormatError) as e:
        print(str(e))
        raise ExitException(1)
    slist.file = dm.get_songlist_path(week)
    slist.week = week
    slist.save()