Exemplo n.º 1
0
def delete_samples(directory, dir_files):
    # nuke any sample files and anything in the extensions to delete string
    # like txt files, nfo files, and jpg files
    for thing_to_delete in dir_files:
        if settings.get_extension(thing_to_delete) in settings.video_formats:
            if is_sample(directory, thing_to_delete):
                settings.debug_message("Found sample movie {}! ENGAGING LASERS"
                                       .format(thing_to_delete))
                os.remove(os.path.join(settings.incoming_dir, directory,
                          thing_to_delete))
        if settings.get_extension(thing_to_delete) in settings.exts_to_delete:
            settings.debug_message("NUKING {}".format(thing_to_delete))
            os.remove(os.path.join(settings.incoming_dir, directory,
                      thing_to_delete))
Exemplo n.º 2
0
def is_video_folder(directory, dir_files):
    for directory_file in dir_files:
        settings.debug_message("Testing file {} for video format!".
                               format(directory_file))
        if settings.get_extension(directory_file) in settings.video_formats:
            settings.debug_message("Found video folder: {}".format(directory))
            return True

    settings.debug_message("Folder does not contain first level video files."
                           " Skipping.")
    return False
Exemplo n.º 3
0
def is_audio_folder(directory, dir_files):
    for directory_file in dir_files:
        settings.debug_message("Testing file {} for audio format!".
                               format(directory_file))
        if settings.get_extension(directory_file) in settings.audio_formats:
            settings.debug_message("Found audio folder: {}".format(directory))
            return True
        else:
            settings.debug_message("Folder does not contain first level audio "
                                   "files. Skipping.")
            return False
Exemplo n.º 4
0
def folder_translator(foldername, title_parser=title_parser):
    '''Uses regex to yoink the name and year out of movie titles.'''
    settings.debug_message("Running folder/name translation on {}".format(
                           foldername))

    # check to see if we're operating on a file or a folder
    if settings.get_extension(foldername) in settings.video_formats:
        extension = settings.get_extension(foldername)
        foldername = foldername[:-len(extension)].replace(".", " ")
        foldername_less_extension = foldername.replace("_", " ")
        foldername = foldername_less_extension + extension
    else:
        foldername = foldername.replace(".", " ")
        foldername = foldername.replace("_", " ")

    foldername = foldername.title()

    settings.debug_message("Now {} after replacement!".format(foldername))
    title_data = title_parser.match(foldername)

    try:
        # try and force an attribute error before it happens
        x = title_data.group("title")
        x = title_data.group("year")
    except AttributeError:
        settings.debug_message("folder_translator - AttributeError!")

        # if it's a folder, foldername_less_extension will not have been
        # created; we catch the unbound error and just use the normal folder
        # name here for that reason
        try:
            title = foldername_less_extension
        except UnboundLocalError:
            title = foldername

        if settings.imdb:
            settings.debug_message("Attempting lookup through IMDbPy!")
            settings.debug_message("IMDbPy - Searching for year of {}".format(
                                   title))
            try:
                maybe_title = imdb_access.search_movie(
                    "{}".format(title))[0]['title']
                settings.debug_message("IMDbPy - I think I found it! It's {}!".
                                       format(maybe_title))
                maybe_year = imdb_access.search_movie(
                    "{}".format(title))[0]['year']
                settings.debug_message("IMDbPy - I think I found it! It's {}!".
                                       format(maybe_year))
                settings.debug_message("IMDbPy - returning ({}, {})".format(
                    maybe_title, maybe_year))
                return(maybe_title, maybe_year)
            except (AttributeError, IndexError):
                # it can't find a title or year! Oh no! Give up for now.
                return None
        else:
            # guess it's not installed. Crap.
            return None

    return (
        title_data.group("title"),
        title_data.group("year")
        )
Exemplo n.º 5
0
def is_movie(directory_file):
    # return true if file is a file type we're looking for

    return (settings.get_extension(directory_file) in settings.video_formats)