Пример #1
0
def main():
    parser = cli.init_argparser()
    parser.add_argument('-f',
                        '--folder_name',
                        help='Elisa Viihde Simpsonit folder name')
    parser.add_argument('-s',
                        '--season_prefix',
                        help='prefix for season folder name')
    params = parser.parse_args()

    username = cli.read_input(params.user, 'Elisa Viihde Username')
    password = cli.read_password(params.passfile, 'Elisa Viihde Password')

    e = elisaviihde.Elisaviihde()
    if not e.login(username, password):
        return

    folder_name = cli.read_input(
        params.folder_name, 'Elisa Viihde Simpsonit folder name [Simpsonit]',
        u'Simpsonit')
    season_folder_name = cli.read_input(
        params.season_prefix,
        'prefix for season folder name or "None" [Season ]', u'Season ')
    if season_folder_name == 'None':
        season_folder_name = u''

    simpsonit_folder = e.find_folder_by_name(folder_name)
    if simpsonit_folder is None:
        print('Folder', folder_name, 'not found')
        return

    episodes = simpsonitorgparser.parse_schedule()
    simpsonit_folder_id = simpsonit_folder['id']
    root_simponit_recordings = e.recordings(simpsonit_folder_id)

    to_be_moved = []  # list of (recording, episode) pairs
    for recording in root_simponit_recordings:
        episode = find_episode(episodes, recording)
        if episode:
            to_be_moved.append((recording, episode))
    print('Found', len(to_be_moved), 'episodes to be moved')

    answer = get_input("Enter 'y' to continue, anything else to cancel: ")
    if answer == 'y':
        for move in to_be_moved:
            recording = move[0]
            episode = move[1]
            target_folder = e.find_or_create_subfolder(
                season_folder_name + str(episode['season']),
                simpsonit_folder_id)
            try:
                status = e.move(recording['programId'], target_folder['id'])
            except TypeError:
                print("Failed to move", recording['programId'])
                continue
            print('MOVED:', status, recording['startTime'], episode['name'],
                  'to', target_folder['name'])
        print("Moving done.")
    else:
        print("Moving canceled.")
Пример #2
0
def main():
    parser = cli.init_argparser()
    parser.add_argument('-f', '--folder_name')
    parser.add_argument('-m', '--max_auto_delete')
    params = parser.parse_args()

    username = cli.read_input(params.user, 'Elisa Viihde Username')
    password = cli.read_password(params.passfile, 'Elisa Viihde Password')

    e = elisaviihde.Elisaviihde()
    if not e.login(username, password):
        return

    folder_name = cli.read_input(params.folder_name,
                                 'Look from folder (enter for all)')
    if folder_name:
        folder = e.find_folder_by_name(folder_name)
        if folder is None:
            print 'Folder', folder_name, 'not found'
            return
    else:
        folder = e.find_folder_by_id(0)

    recordings = e.ls_recordings_recursive(folder, [])
    found_duplicates = find_duplicates(recordings)

    answer = 'n'
    if params.max_auto_delete is not None:
        if len(found_duplicates) <= int(params.max_auto_delete):
            answer = 'y'
    elif len(found_duplicates) > 0:
        answer = raw_input(
            "Enter 'y' to delete duplicates, anything else to cancel: ")

    if answer == 'y':
        for key, recordings in found_duplicates.iteritems():
            print 'Processing:', key[0], ';', key[1]
            first = True
            for recording in recordings:
                if first:
                    print 'Kept first', recording['startTime'], recording[
                        'channel']
                    first = False
                else:
                    status = e.delete(recording['programId'])
                    print 'DELETED', status, recording['startTime'], recording[
                        'channel']
        print 'Delete duplicates done.'
    else:
        print 'Delete duplicates canceled.'
        exit(-1)
Пример #3
0
def main():
    parser = cli.init_argparser()
    parser.add_argument('-f', '--folder_name', help='Elisa Viihde Simpsonit folder name')
    parser.add_argument('-s', '--season_prefix', help='prefix for season folder name')
    params = parser.parse_args()

    username = cli.read_input(params.user, 'Elisa Viihde Username')
    password = cli.read_password(params.passfile, 'Elisa Viihde Password')

    e = elisaviihde.Elisaviihde()
    if not e.login(username, password):
        return

    folder_name = cli.read_input(params.folder_name,
                                 'Elisa Viihde Simpsonit folder name [Simpsonit]',
                                 u'Simpsonit')
    season_folder_name = cli.read_input(params.season_prefix,
                                        'prefix for season folder name or "None" [Season ]',
                                        u'Season ')
    if season_folder_name == 'None':
        season_folder_name = u''

    simpsonit_folder = e.find_folder_by_name(folder_name)
    if simpsonit_folder is None:
        print 'Folder', folder_name, 'not found'
        return
    
    episodes = simpsonitorgparser.parse_schedule()
    simpsonit_folder_id = simpsonit_folder['id']
    root_simponit_recordings = e.recordings(simpsonit_folder_id)
    
    to_be_moved = []  # list of (recording, episode) pairs
    for recording in root_simponit_recordings:
        episode = find_episode(episodes, recording)
        if episode:
            to_be_moved.append((recording, episode))
    print 'Found', len(to_be_moved), 'episodes to be moved'

    answer = raw_input("Enter 'y' to continue, anything else to cancel: ")
    if answer == 'y':
        for move in to_be_moved:
            recording = move[0]
            episode = move[1]
            target_folder = e.find_or_create_subfolder(season_folder_name + str(episode['season']),
                                                       simpsonit_folder_id)
            status = e.move(recording['programId'], target_folder['id'])
            print 'MOVED:', status, recording['startTime'], episode['name'], 'to', target_folder['name']
        print "Moving done."
    else:
        print "Moving canceled."
Пример #4
0
def main():
    parser = cli.init_argparser()
    parser.add_argument('-f', '--folder_name')
    parser.add_argument('-m', '--max_auto_delete')
    params = parser.parse_args()

    username = cli.read_input(params.user, 'Elisa Viihde Username')
    password = cli.read_password(params.passfile, 'Elisa Viihde Password')

    e = elisaviihde.Elisaviihde()
    if not e.login(username, password):
        return
          
    folder_name = cli.read_input(params.folder_name, 'Look from folder (enter for all)')
    if folder_name:
        folder = e.find_folder_by_name(folder_name)
        if folder is None:
            print('Folder', folder_name, 'not found')
            return
    else:
        folder = e.find_folder_by_id(0)

    recordings = e.ls_recordings_recursive(folder, [])
    found_duplicates = find_duplicates(recordings)
    
    answer = 'n'
    if params.max_auto_delete is not None:
        if len(found_duplicates) <= int(params.max_auto_delete):
            answer = 'y'
    elif len(found_duplicates) > 0:
        answer = get_input("Enter 'y' to delete duplicates, anything else to cancel: ")
    
    if answer == 'y':
        for key, recordings in found_duplicates.items():
            print('Processing:', key[0], ';', key[1])
            first = True
            for recording in recordings:
                if first:
                    print('Kept first', recording['startTime'], recording['channel'])
                    first = False
                else:
                    status = e.delete(recording['programId'])
                    print('DELETED', status, recording['startTime'], recording['channel'])
        print('Delete duplicates done.')
    else:
        print('Delete duplicates canceled.')
        exit(-1)
Пример #5
0
def main():
    parser = cli.init_argparser()
    params = parser.parse_args()

    username = cli.read_input(params.user, 'Elisa Viihde Username')
    password = cli.read_password(params.passfile, 'Elisa Viihde Password')

    e = elisaviihde.Elisaviihde(params.verbose)

    if not e.login(username, password):
        exit(-1)

    # From root up
    folder = e.find_folder_by_id(0)

    recordings = e.ls_recordings_recursive(folder, [])
    found_duplicates = find_duplicates(recordings, params.verbose)

    # If nothing to delete, end
    if len(found_duplicates) < 1:
        return

    # Loop-de-loop
    for key, recordings in found_duplicates.iteritems():
        if params.verbose > 0:
            print 'Processing:', key[0], ';', key[1]
        first = True
        for recording in recordings:
            if first:
                if params.verbose > 1:
                    print 'Kept first', recording['startTime'], recording[
                        'channel']
                first = False
            else:
                status = e.delete(recording['programId'])
                if params.verbose > 2:
                    print 'DELETED', status, recording['startTime'], recording[
                        'channel']
    if params.verbose > 0:
        print 'Delete duplicates done.'
Пример #6
0
def main():
    parser = cli.init_argparser()
    params = parser.parse_args()

    username = cli.read_input(params.user, 'Elisa Viihde Username')
    password = cli.read_password(params.passfile, 'Elisa Viihde Password')

    e = elisaviihde.Elisaviihde(params.verbose)

    if not e.login(username, password):
        exit(-1)

    # From root up
    folder = e.find_folder_by_id(0)

    recordings = e.ls_recordings_recursive(folder, [])
    found_duplicates = find_duplicates(recordings, params.verbose)

    # If nothing to delete, end
    if len(found_duplicates) < 1:
        return

    # Loop-de-loop
    for key, recordings in found_duplicates.iteritems():
        if params.verbose > 0:
            print 'Processing:', key[0], ';', key[1]
        first = True
        for recording in recordings:
            if first:
                if params.verbose > 1:
                    print 'Kept first', recording['startTime'], recording['channel']
                first = False
            else:
                status = e.delete(recording['programId'])
                if params.verbose > 2:
                    print 'DELETED', status, recording['startTime'], recording['channel']
    if params.verbose > 0:
        print 'Delete duplicates done.'
Пример #7
0
    if save:
        joblib.dump(model, save_path + 'model.pkl')
        joblib.dump(S_test, save_path + 'S_test.pkl')
        joblib.dump(y_test, save_path + 'y_test.pkl')


def predicting(load_path):
    model = joblib.load(load_path + 'model.pkl')
    S_test = joblib.load(load_path + 'S_test.pkl')
    y_test = joblib.load(load_path + 'y_test.pkl')
    run_predict((model, S_test, y_test))


if ENV == 'PREPROCESS':
    try:
        load_path, save_path, save_flag = init_argparser('preprocess')
        preprocessing(load_path, save_path, save_flag)
    except Exception as e:
        print(e)

if ENV == 'FEATURES':
    try:
        load_path, save_path, save_flag = init_argparser('feature engineering')
        features_eng(load_path, save_path, save_flag)
    except Exception as e:
        print(e)

if ENV == 'TRAIN':
    try:
        load_path, save_path, save_flag = init_argparser('training')
        training(load_path, save_path, save_flag)