<commit_before>#!/usr/bin/python3
# media_namer.py - Renames passed media files

import shutil
import os
import sys
import tqdm
from distutils.util import strtobool
import videoLister
import scrapeOMDB
import regSplit

in_path = ' '.join(sys.argv[1:])

media_list = videoLister.videoDir(in_path)
files_no_response = []
for item in tqdm.tqdm(media_list):
    med_info = {}
    reg_dict = regSplit.Split(item)
    ext = os.path.splitext(item)[1]

    if reg_dict['type'] == 'tv':
        med_info = scrapeOMDB.OMDBtv(reg_dict['title'], reg_dict['season'],
                                    reg_dict['episode'])

        if strtobool(med_info['Response']):
            new_name = (reg_dict['title'] + ' S' + med_info['Season'].zfill(2) +
                        'E' + med_info['Episode'].zfill(2) + ' - ' +
                        med_info['Title'] + ext)
            shutil.move(item, (os.path.join(os.path.dirname(item), new_name)))
        else:
            files_no_response.append(item)

    if reg_dict['type'] == 'movie':
        med_info = scrapeOMDB.OMDBmovie(reg_dict['title'], reg_dict['year'])

        if strtobool(med_info['Response']):
            new_name = (reg_dict['title'] + '(' + med_info['Year'] + ')' + ext)
            shutil.move(item, (os.path.join(os.path.dirname(item), new_name)))
        else:
            files_no_response.append(item)

if files_no_response:
    print('Files without a response:', files_no_response)<commit_msg>convert to work with videoLister generator<commit_after>#!/usr/bin/python3
# media_namer.py - Renames passed media files

import shutil
import os
import sys
import tqdm
from distutils.util import strtobool
import videoLister
import scrapeOMDB
import regSplit

in_path = ' '.join(sys.argv[1:])

files_no_response = []
for item in tqdm.tqdm(videoLister.videoDir(in_path)):
    med_info = {}
    reg_dict = regSplit.Split(item)
    ext = os.path.splitext(item)[1]

    if reg_dict['type'] == 'tv':
        med_info = scrapeOMDB.OMDBtv(reg_dict['title'], reg_dict['season'],
                                    reg_dict['episode'])

        if strtobool(med_info['Response']):
            new_name = (reg_dict['title'] + ' S' + med_info['Season'].zfill(2) +
                        'E' + med_info['Episode'].zfill(2) + ' - ' +
                        med_info['Title'] + ext)
            shutil.move(item, (os.path.join(os.path.dirname(item), new_name)))
        else:
            files_no_response.append(item)

    if reg_dict['type'] == 'movie':
        med_info = scrapeOMDB.OMDBmovie(reg_dict['title'], reg_dict['year'])

        if strtobool(med_info['Response']):
            new_name = (reg_dict['title'] + '(' + med_info['Year'] + ')' + ext)
            shutil.move(item, (os.path.join(os.path.dirname(item), new_name)))
        else:
            files_no_response.append(item)

if files_no_response:
    print('Files without a response:', files_no_response)
{'fraction_non_alphanumeric': 0.1468675111263266, 'fraction_numerical': 0.003423485107839781, 'mean_word_length': 2.799739921976593, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1402934', 'n_tokens_mistral': 1001, 'n_tokens_neox': 975, 'n_words': 170}