예제 #1
0
파일: uploader.py 프로젝트: razage/PlexOps
def uploadfiles(plexops_app):
    uploader_regex = {"name": compile(plexops_app.get_settings('plexname_regex')),
                      "season": compile(plexops_app.get_settings('plexseason_regex')),
                      "episode": compile(plexops_app.get_settings('plexep_regex'))}

    if not isdir(plexops_app.get_settings('server_location')):
        print("[%s] Server unreachable. Aborting..." % getcurrenttime())
        plexops_app.abort()

    for files in listdir(plexops_app.get_settings('operation_location')):
        if files.endswith(".mkv") and files[0] != "[":
            fdata = {'file': files, 'series': uploader_regex['name'].match(files).group(1),
                     'season': uploader_regex['season'].match(files).group(1),
                     'episode': uploader_regex['episode'].match(files).group(1)}
            fdata['season'] = str(int(fdata['season']))
            if not isdir(join(plexops_app.server_location, fdata['series'], "Season " + fdata['season'])):
                makedirs(join(plexops_app.server_location, fdata['series'], "Season " + fdata['season']))
                print("[%s] Created directory for %s Season %s" % (getcurrenttime(), fdata['series'], fdata['season']))

            move(join(plexops_app.operation_location, fdata['file']),
                 join(plexops_app.server_location, fdata['series'], "Season " + fdata['season'], fdata['file']))
            print("[%s] Moved %s s%se%s to the server." % (
            getcurrenttime(), fdata['series'], fdata['season'], fdata['episode']))
예제 #2
0
파일: renamer.py 프로젝트: razage/PlexOps
def rename(plexops_app):
    rename_regex = {'name': compile(plexops_app.get_settings('name_regex')),
                    'episode': compile(plexops_app.get_settings('episode_regex'))}

    for files in listdir(plexops_app.operation_location):
        if files.endswith(".mkv") and files[0] == "[":
            fdata = {"location": files, "name": rename_regex['name'].match(files).group(1),
                     "ep": padandstringify(rename_regex['episode'].match(files).group(1)), "season": "01"}
            fdata['name'] = fdata['name'].replace("_", " ")
            if fdata['name'] in plexops_app.get_settings('show_settings'):
                print("[%s] Series %s has settings configured. Adjusting data..." % (getcurrenttime(), fdata['name']))
                _showsettings = plexops_app.get_showsettings(fdata['name'])
                if 'season' in _showsettings:
                    fdata['season'] = padandstringify(_showsettings['season'])
                if 'adjust' in _showsettings:
                    fdata['ep'] = padandstringify(int(fdata['ep']) - _showsettings['adjust'])
                if 'altname' in _showsettings:
                    fdata['name'] = _showsettings['altname']

            move(join(plexops_app.operation_location, fdata['location']), join(plexops_app.operation_location,
                                                                               "%s - s%se%s.mkv" % (
                                                                                   fdata['name'], fdata['season'],
                                                                                   fdata['ep'])))
예제 #3
0
from PlexOps import getcurrenttime, PlexOps
from PlexOps.renamer import rename
from PlexOps.uploader import uploadfiles

if __name__ == "__main__":
    p = PlexOps()
    print("[%s] Starting renamer..." % getcurrenttime())
    rename(p)
    print("[%s] Renaming complete. \n[%s] Starting uploader..." % (getcurrenttime(), getcurrenttime()))
    uploadfiles(p)
    print("[%s] Uploading complete. Aborting PlexOps..." % getcurrenttime())
    p.abort()