Example #1
0
def extract_mov(folder):
    source_path = os.path.join(CWD, folder)
    if not check_valid_source_folder(source_path):
        return
    dest_path = os.path.join(movie.root_path(), movie.determine_letter(folder),
                             folder)
    rar_file = filetools.get_file(source_path, "rar")
    nfo_file = filetools.get_file(source_path, "nfo")
    if rar_file is None:
        PRINT.warning(f"could not find .rar in [{folder}]")
        return
    source_file = os.path.join(source_path, rar_file)
    PRINT.info("Found rar-file: [ {} ]".format(os.path.basename(source_file)))
    if user_input.yes_no("Extract to: [ {} ]".format(dest_path),
                         script_name=os.path.basename(__file__)):
        os.system("unrar e \"{}\" \"{}\"".format(source_file, dest_path))
    else:
        return
    if nfo_file is not None:
        pattern = re.compile("tt\d{2,}")
        nfo_file = os.path.join(source_path, nfo_file)
        with open(nfo_file, 'r', encoding='utf-8', errors='ignore') as nfo:
            for line in nfo:
                match = re.search(pattern, line)
                if match:
                    imdb_id = match[0]
                    PRINT.info(
                        "Found IMDb-id in nfo-file: [ {} ]".format(imdb_id))
                    filetools.create_nfo(
                        dest_path,
                        "http://www.imdb.com/title/{}".format(imdb_id),
                        "movie")
Example #2
0
def nfo_to_imdb(path):
    if not has_nfo(path):
        return None
    f = open(ftool.get_file(path, "nfo", full_path=True), "r")
    imdb_url = f.readline()
    f.close()
    re_imdb = re.compile("tt\d{1,}")
    imdb_id = re_imdb.search(imdb_url)
    return imdb_id.group(0) if imdb_id else None
Example #3
0
def has_subtitle(show_d, ep_file_name, lang):
    if lang != "en" and lang != "sv":
        pr.error(f"got wrong lang for has_subtitle: {lang}")
        return None
    show_d = to_show_d(show_d)
    show_folder = show_d["folder"]
    season = guess_season(ep_file_name)
    path = _show_path_season(show_folder, season)
    srt_file_to_find = ep_file_name[:-3] + f"{lang}.srt"
    return ftool.get_file(path, srt_file_to_find)
Example #4
0
def extract_ep(folder):
    src = os.path.join(CWD, folder)
    dest = tvshow.show_season_path_from_ep_s(folder)
    rar_file = filetools.get_file(src, "rar")
    if rar_file is None:
        PRINT.warning(f"could not find .rar in [{folder}]")
        return
    src_rar = os.path.join(src, rar_file)
    PRINT.info(f"found rar-file: [{rar_file}]")
    PRINT.info(f'extract [{folder}]')
    PRINT.info(f'------> [{dest}]')
    if user_input.yes_no("proceed with extraction?", script_name=None):
        os.system("unrar e \"{}\" \"{}\"".format(src_rar, dest))
        PRINT.info("done!")
Example #5
0
def get_vid_file(path):
    for ext in ["mkv", "avi", "mp4"]:
        vid = ftool.get_file(path, ext)
        if vid:
            return vid
    return None
Example #6
0
def has_nfo(path):
    return True if ftool.get_file(path, "nfo") is not None else False
Example #7
0
def has_subtitle(path, lang):
    return ftool.get_file(path, lang + ".srt")