Пример #1
0
def dirA_complete(tmpdir_factory):
    testbed = tmpdir_factory.mktemp('testA_complete')
    for m in movies:
        tempmovie = testbed.mkdir('/' + m).join('/movie.mp4')
        tempmovie.write('movie code')
    search = cf.Cinefiles(searchfolder=str(testbed))
    search.run()
    return testbed
Пример #2
0
def test_metadata(directoryB):
    newsearch = cf.Cinefiles(searchfolder=str(directoryB))
    for m in moviesB:
        pathobj = directoryB.join('/' + m)
        resultdict = newsearch.getattrfrommetadata(str(pathobj))
        print(str(pathobj))
        for key in resultdict:
            if (key != 'indexfile'):
                #indexfile is set later
                print(key)
                assert resultdict[key] != ''
Пример #3
0
def test_checkarchive(dirA_complete, monkeypatch):
    monkeypatch.chdir(dirA_complete)
    assert dirA_complete.join('/5th Element/index.htm').exists()
    newsearch = cf.Cinefiles(searchfolder=str(dirA_complete))
    #     newsearch.run()
    it = os.scandir(str(dirA_complete))
    for entry in it:
        if entry.is_dir():
            subit = os.scandir(entry.path)
            for subentry in subit:
                if (subentry.name == 'archive.log'
                        or subentry.name == '.archive.log'):
                    assert newsearch.checkarchive(subentry)
Пример #4
0
def test_fullsetup():
    full = cf.Cinefiles(guess=False,
                        skip=False,
                        test=False,
                        destroy=False,
                        debugnum=3,
                        localresources=False,
                        searchfolder=False)

    for key in {
            'guess', 'skip', 'test', 'destroy', 'localresources',
            'searchfolder'
    }:
        assert full.configdict[key] == False

    assert full.configdict['debugnum'] == 3
Пример #5
0
def test_examplerunA(directoryA, examples, monkeypatch):
    monkeypatch.chdir(examples)

    import cinefiles.cinefiles as cf
    import logging
    search = cf.Cinefiles(configfile=str(examples) + '/cinefiles.ini')
    #we must change searchfolder to temporary directory
    search.configdict.update({'searchfolder': str(directoryA)})
    search.run()
    #check basic structure
    for item in directoryA.listdir():
        if (item.isdir()):
            foldername = str(item).split('/')[-1]
            print(foldername)
            if (foldername != 'cinefiles' and foldername != '.cinefiles'):
                index = item.join('/index.htm')
                assert index.exists()
Пример #6
0
#! /usr/bin/env python3

import cinefiles.cinefiles as cf
import logging

search = cf.Cinefiles(configfile='cinefiles.ini')
# search = cf.Cinefiles()

search.run()
Пример #7
0
def cinefilesHandler(argv):
    import logging

    # defaultFolder = "/Volumes/Holland Gibson Ext HDD/Movies/Movies"
    defaultFolder = "~/Movies/"

    help_string = (
        "cinefiles -f <folder to improve> [options]  \n"
        "-h\t\tPrint this help menu\n-f <folder>\tWhich folder to search\n"
        "-d\t\tDefault folder: " + defaultFolder + '\n'
        "-t\t\tTest, don't download or modify anything just search TMDb\n"
        "-g\t\tNon-interactive, make best guess and carry on\n"
        "-s\t\tSkip questionable movies (don't guess either)\n"
        "--force\t\tRe-download all files (but save old ones)\n"
        "--force-destroy\tRe-download all files and DELETE old ones "
        "(this overrides '--force')\n"
        "\nNote: this only works when movies are in their own folders. "
        "\nYou can run 'cinefolders' to do that for you.\n")

    try:
        opts, args = getopt.getopt(argv, "hdf:tgs",
                                   ["force", "force-destroy", "debug:"])
    except getopt.GetoptError:
        print(help_string)
        sys.exit(2)

    searchfolder = ''
    guess_flag = False
    skip_flag = False
    test_flag = False
    force_flag = False
    destroy_flag = False
    log = logging.INFO

    flags = ""

    for opt, arg in opts:
        if opt == '-h':
            print(help_string)
            sys.exit(2)
        elif opt == '-f':
            searchfolder = arg
            flags += " -f " + arg
        elif opt == '-t':
            test_flag = True
            flags += " -t"
        elif opt == '-s':
            skip_flag = True
            flags += " -s"
        elif opt == '-g':
            guess_flag = True
            flags += " -g"
        elif opt == '-d':
            searchfolder = defaultFolder
            flags += " -f " + defaultFolder
        elif opt == "force":
            force_flag = True
            flags += " --force"
        elif opt == "force-destroy":
            force_flag = True
            destroy_flag = True
            flags += " --force-destroy"
        elif opt == "debug":
            debug_num = int(arg)
            flags += " --debug " + arg

    if (searchfolder == ''):
        print("You must specify a folder! (-f <folder>) or (-d)\n-h for help")
        sys.exit(2)

    if (log > 0):
        print("Running with:" + flags)

    print('Search folder is: ' + searchfolder)
    if (test_flag):
        print("TEST mode")
        force_flag = False
        destroy_flag = False
    if (skip_flag):
        print("Skipping questionable movies")
    if (not skip_flag and not guess_flag):
        print("DON'T QUESTION MY AUTHORITY!!")
    if (force_flag and not destroy_flag):
        print(
            "Let's get new files this time, but I'm attached to the old ones")
    if (force_flag and destroy_flag):
        print("DELETE those old files, let's get new ones")

    print("")

    search = cf.Cinefiles(searchfolder, guess_flag, skip_flag, test_flag,
                          force_flag, destroy_flag, log)

    search.run()
Пример #8
0
def test_broken_conf(broken_ini, monkeypatch):
    monkeypatch.chdir(broken_ini)
    with pytest.raises(ValueError) as err:
        tc = cf.Cinefiles()
Пример #9
0
def test_no_conf(blank_folder, monkeypatch):
    monkeypatch.chdir(blank_folder)
    with pytest.raises(IOError) as err:
        tc = cf.Cinefiles()
Пример #10
0
def test_no_args(min_ini, monkeypatch):
    monkeypatch.chdir(min_ini)
    tc = cf.Cinefiles()
    assert tc.configdict['searchfolder'] == 'none'