Example #1
0
def do_process_movies(config, debug, move):
    thetvdb = TheTvDb(config, debug)
    moviedb = MovieDB(config, debug)
    database = Database(config, debug)
    file_manager = FileManager(config, database, thetvdb, moviedb, debug)

    lock = file_manager.get_process_lock()

    if lock is None:
        print "Another instance of media_library_manager is currently processing.  Exiting."
        return 3

    try:
        movie_input_path = config.getLibraryMovieInputPath()
        movie_path = config.getLibraryMoviePath()
        movie_genre_path = config.getLibraryMovieGenrePath()

        if movie_input_path is None:
            print "Configuration setting 'movie_input_path' in section 'Library' is missing. Will not attempt processing of movies."
        elif movie_path is None:
            print "Configuration setting 'movie_path' in section 'Library' is missing. Will not attempt processing of movies."
        else:
            process_movies(movie_input_path, movie_path, movie_genre_path, file_manager, debug, move)

        file_manager.cleanup_recent_folder()
    except:
        traceback.print_exc()
        return 11
    finally:
        file_manager.relinquish_process_lock()
Example #2
0
def do_process(config, debug, move):
    thetvdb = TheTvDb(config, debug)
    database = Database(config, debug)
    file_manager = FileManager(config, database, thetvdb, debug)

    lock = file_manager.get_process_lock()

    if lock is None:
        print "Another instance of media_library_manager is currently processing.  Exiting."
        return 3
    else:
        try:
            input_path = config.getLibraryInputPath()
            tv_path = config.getLibraryTvPath()

            if not os.path.exists(input_path):
                print "Input path '%s' does not exist. Exiting." % input_path,
                return 1

            if not os.path.exists(tv_path):
                print "Library TV path '%s' does not exist. Exiting." % tv_path,
                return 2

            files = []
            for root, dir, files_to_add in os.walk(input_path):
                for file in files_to_add:
                    if file_manager.is_media_file(file):
                        files.append((root, file))

            input_contents = os.listdir(input_path)
            for (root, file) in files:
                file_path = os.path.join(root, file)
                if os.path.isfile(file_path):
                    process_file(file_manager, file_path, tv_path, debug, move)

            file_manager.cleanup_recent_folder()
        except:
            traceback.print_exc()
            return 11
        finally:
            file_manager.relinquish_process_lock()
Example #3
0
def do_process_tv(config, debug, move):
    thetvdb = TheTvDb(config, debug)
    moviedb = MovieDB(config, debug)
    database = Database(config, debug)
    file_manager = FileManager(config, database, thetvdb, moviedb, debug)

    lock = file_manager.get_process_lock()

    if lock is None:
        print "Another instance of media_library_manager is currently processing.  Exiting."
        return 3

    try:
        input_path = config.getLibraryInputPath()
        tv_path = config.getLibraryTvPath()
        tv_genre_path = config.getLibraryTvGenrePath()

        process_tv(input_path, tv_path, tv_genre_path, file_manager, debug, move)
        file_manager.cleanup_recent_folder()
    except:
        traceback.print_exc()
        return 11
    finally:
        file_manager.relinquish_process_lock()