Esempio n. 1
0
    def _run_import(self, titles=TEST_TITLES, delete=False, threaded=False):
        # Make a bunch of tracks to import.
        paths = []
        for i, title in enumerate(titles):
            paths.append(
                self._create_test_file(
                    ['the_album', 'track_%s.mp3' % (i + 1)], {
                        'track': (i + 1),
                        'artist': 'The Artist',
                        'album': 'The Album',
                        'title': title,
                    }))

        # Run the UI "beet import" command!
        importer.run_import(
            lib=self.lib,
            paths=[os.path.dirname(paths[0])],
            copy=True,
            write=True,
            autot=False,
            logfile=None,
            art=False,
            threaded=threaded,
            color=False,
            delete=delete,
            quiet=True,
            resume=False,
            quiet_fallback='skip',
            choose_match_func=None,
            should_resume_func=None,
            singletons=False,
            choose_item_func=None,
        )

        return paths
Esempio n. 2
0
    def _run_import(self, titles=TEST_TITLES, delete=False, threaded=False):
        # Make a bunch of tracks to import.
        paths = []
        for i, title in enumerate(titles):
            paths.append(
                self._create_test_file(
                    ["the_album", "track_%s.mp3" % (i + 1)],
                    {"track": (i + 1), "artist": "The Artist", "album": "The Album", "title": title},
                )
            )

        # Run the UI "beet import" command!
        importer.run_import(
            lib=self.lib,
            paths=[os.path.dirname(paths[0])],
            copy=True,
            write=True,
            autot=False,
            logfile=None,
            art=False,
            threaded=threaded,
            color=False,
            delete=delete,
            quiet=True,
            resume=False,
            quiet_fallback="skip",
            choose_match_func=None,
            should_resume_func=None,
            singletons=False,
            choose_item_func=None,
        )

        return paths
Esempio n. 3
0
    def _run_import(self, titles=TEST_TITLES, delete=False, threaded=False,
                    singletons=False, move=False):
        # Make a bunch of tracks to import.
        paths = []
        for i, title in enumerate(titles):
            paths.append(self._create_test_file(
                ['the_album', 'track_%s.mp3' % (i+1)],
                {
                    'track': (i+1),
                    'artist': 'The Artist',
                    'album': 'The Album',
                    'title': title,
                }))

        # Run the UI "beet import" command!
        importer.run_import(
            lib=self.lib,
            paths=[os.path.dirname(paths[0])],
            copy=not move,
            move=move,
            write=True,
            autot=False,
            logfile=None,
            art=False,
            threaded=threaded,
            color=False,
            delete=delete,
            quiet=True,
            resume=False,
            quiet_fallback='skip',
            choose_match_func = None,
            should_resume_func = None,
            singletons = singletons,
            choose_item_func = None,
            timid = False,
            query = None,
            incremental = False,
            ignore = [],
            resolve_duplicate_func = None,
            per_disc_numbering = False,
        )

        return paths
Esempio n. 4
0
    def _run_import(self, titles=TEST_TITLES, delete=False, threaded=False, singletons=False, move=False):
        # Make a bunch of tracks to import.
        paths = []
        for i, title in enumerate(titles):
            paths.append(
                self._create_test_file(
                    ["the_album", "track_%s.mp3" % (i + 1)],
                    {"track": (i + 1), "artist": "The Artist", "album": "The Album", "title": title},
                )
            )

        # Run the UI "beet import" command!
        importer.run_import(
            lib=self.lib,
            paths=[os.path.dirname(paths[0])],
            copy=not move,
            move=move,
            write=True,
            autot=False,
            logfile=None,
            threaded=threaded,
            color=False,
            delete=delete,
            quiet=True,
            resume=False,
            quiet_fallback="skip",
            choose_match_func=None,
            should_resume_func=None,
            singletons=singletons,
            choose_item_func=None,
            timid=False,
            query=None,
            incremental=False,
            ignore=[],
            resolve_duplicate_func=None,
            per_disc_numbering=False,
            strong_rec_thresh=None,
            medium_rec_thresh=None,
            rec_gap_thresh=None,
        )

        return paths
Esempio n. 5
0
def import_files(lib, paths, copy, move, write, autot, logpath, art, threaded,
                 color, delete, quiet, resume, quiet_fallback, singletons,
                 timid, query, incremental, ignore, per_disc_numbering):
    """Import the files in the given list of paths, tagging each leaf
    directory as an album. If copy, then the files are copied into
    the library folder. If write, then new metadata is written to the
    files themselves. If not autot, then just import the files
    without attempting to tag. If logpath is provided, then untaggable
    albums will be logged there. If art, then attempt to download
    cover art for each album. If threaded, then accelerate autotagging
    imports by running them in multiple threads. If color, then
    ANSI-colorize some terminal output. If delete, then old files are
    deleted when they are copied. If quiet, then the user is
    never prompted for input; instead, the tagger just skips anything
    it is not confident about. resume indicates whether interrupted
    imports can be resumed and is either a boolean or None.
    quiet_fallback should be either ASIS or SKIP and indicates what
    should happen in quiet mode when the recommendation is not strong.
    """
    # Check the user-specified directories.
    for path in paths:
        if not singletons and not os.path.isdir(syspath(path)):
            raise ui.UserError('not a directory: ' + path)
        elif singletons and not os.path.exists(syspath(path)):
            raise ui.UserError('no such file: ' + path)

    # Check parameter consistency.
    if quiet and timid:
        raise ui.UserError("can't be both quiet and timid")

    # Open the log.
    if logpath:
        logpath = normpath(logpath)
        try:
            logfile = open(syspath(logpath), 'a')
        except IOError:
            raise ui.UserError(u"could not open log file for writing: %s" %
                               displayable_path(logpath))
        print('import started', time.asctime(), file=logfile)
    else:
        logfile = None

    # Never ask for input in quiet mode.
    if resume is None and quiet:
        resume = False

    try:
        # Perform the import.
        importer.run_import(
            lib = lib,
            paths = paths,
            resume = resume,
            logfile = logfile,
            color = color,
            quiet = quiet,
            quiet_fallback = quiet_fallback,
            copy = copy,
            move = move,
            write = write,
            art = art,
            delete = delete,
            threaded = threaded,
            autot = autot,
            choose_match_func = choose_match,
            should_resume_func = should_resume,
            singletons = singletons,
            timid = timid,
            choose_item_func = choose_item,
            query = query,
            incremental = incremental,
            ignore = ignore,
            resolve_duplicate_func = resolve_duplicate,
            per_disc_numbering = per_disc_numbering,
        )

    finally:
        # If we were logging, close the file.
        if logfile:
            print('', file=logfile)
            logfile.close()

    # Emit event.
    plugins.send('import', lib=lib, paths=paths)
Esempio n. 6
0
def import_files(lib, paths, copy, write, autot, logpath, art, threaded, color,
                 delete, quiet, resume, quiet_fallback, singletons, timid,
                 query, incremental, ignore):
    """Import the files in the given list of paths, tagging each leaf
    directory as an album. If copy, then the files are copied into
    the library folder. If write, then new metadata is written to the
    files themselves. If not autot, then just import the files
    without attempting to tag. If logpath is provided, then untaggable
    albums will be logged there. If art, then attempt to download
    cover art for each album. If threaded, then accelerate autotagging
    imports by running them in multiple threads. If color, then
    ANSI-colorize some terminal output. If delete, then old files are
    deleted when they are copied. If quiet, then the user is
    never prompted for input; instead, the tagger just skips anything
    it is not confident about. resume indicates whether interrupted
    imports can be resumed and is either a boolean or None.
    quiet_fallback should be either ASIS or SKIP and indicates what
    should happen in quiet mode when the recommendation is not strong.
    """
    # Check the user-specified directories.
    for path in paths:
        if not singletons and not os.path.isdir(syspath(path)):
            raise ui.UserError('not a directory: ' + path)
        elif singletons and not os.path.exists(syspath(path)):
            raise ui.UserError('no such file: ' + path)

    # Check parameter consistency.
    if quiet and timid:
        raise ui.UserError("can't be both quiet and timid")

    # Open the log.
    if logpath:
        logpath = normpath(logpath)
        logfile = open(syspath(logpath), 'a')
        print >> logfile, 'import started', time.asctime()
    else:
        logfile = None

    # Never ask for input in quiet mode.
    if resume is None and quiet:
        resume = False

    # Perform the import.
    importer.run_import(
        lib=lib,
        paths=paths,
        resume=resume,
        logfile=logfile,
        color=color,
        quiet=quiet,
        quiet_fallback=quiet_fallback,
        copy=copy,
        write=write,
        art=art,
        delete=delete,
        threaded=threaded,
        autot=autot,
        choose_match_func=choose_match,
        should_resume_func=should_resume,
        singletons=singletons,
        timid=timid,
        choose_item_func=choose_item,
        query=query,
        incremental=incremental,
        ignore=ignore,
    )

    # If we were logging, close the file.
    if logfile:
        print >> logfile, ''
        logfile.close()

    # Emit event.
    plugins.send('import', lib=lib, paths=paths)
Esempio n. 7
0
def import_files(lib, paths, copy, write, autot, logpath, art, threaded,
                 color, delete, quiet, resume, quiet_fallback, singletons,
                 interactive_autotag):
    """Import the files in the given list of paths, tagging each leaf
    directory as an album. If copy, then the files are copied into
    the library folder. If write, then new metadata is written to the
    files themselves. If not autot, then just import the files
    without attempting to tag. If logpath is provided, then untaggable
    albums will be logged there. If art, then attempt to download
    cover art for each album. If threaded, then accelerate autotagging
    imports by running them in multiple threads. If color, then
    ANSI-colorize some terminal output. If delete, then old files are
    deleted when they are copied. If quiet, then the user is
    never prompted for input; instead, the tagger just skips anything
    it is not confident about. resume indicates whether interrupted
    imports can be resumed and is either a boolean or None.
    quiet_fallback should be either ASIS or SKIP and indicates what
    should happen in quiet mode when the recommendation is not strong.
    """
    # Check the user-specified directories.
    for path in paths:
        if not os.path.isdir(syspath(path)):
            raise ui.UserError('not a directory: ' + path)

    # Open the log.
    if logpath:
        logfile = open(logpath, 'w')
    else:
        logfile = None

    # Never ask for input in quiet mode.
    if resume is None and quiet:
        resume = False

    # Perform the import.
    importer.run_import(
        lib = lib,
        paths = paths,
        resume = resume,
        logfile = logfile,
        color = color,
        quiet = quiet,
        quiet_fallback = quiet_fallback,
        copy = copy,
        write = write,
        art = art,
        delete = delete,
        threaded = threaded,
        autot = autot,
        choose_match_func = choose_match,
        should_resume_func = should_resume,
        singletons = singletons,
        interactive_autotag = interactive_autotag,
        choose_item_func = choose_item,
    )
    
    # If we were logging, close the file.
    if logfile:
        logfile.close()

    # Emit event.
    plugins.send('import', lib=lib, paths=paths)