Example #1
0
def partRename(searchPath, recursive, extension, renameVideo, renameSub, verbose):
    videoFiles = []
    subFiles = []
    
    if renameVideo:
        videoFiles = findVideoFiles(searchPath, recursive, videoFiles, verbose)
        
    if renameSub:
        subFiles = findSubFiles(searchPath, recursive, extension, subFiles, False, verbose)
        
    if videoFiles:
        print "Videos found:"
        for videoFile in videoFiles:
            print videoFile
        print
    if subFiles:
        print "Subtitles found:"
        for subFile in subFiles:
            print subFile
        print
Example #2
0
def partLink(recursive, searchPath, extension, fileMask, verbose):  # finds out language of sub, inserts it, and creates link
    langSums = []
    subFiles = []

    subFiles = findSubFiles(searchPath, recursive, extension, subFiles, False, verbose)

    if subFiles: 
        for myFile in subFiles:
            print "\n%s" % myFile
            if fileMask in os.path.basename(myFile):
                langSums = fileFound(myFile, langSums, verbose)  # go ahead with the file
            else:
                print "*** File name does not match the mask"

    print "\nLanguages found:"
    for lang in languages:
        langSum = langSums.count(lang['code'])  # adds languages found
        if langSums.count(lang['code']) > 0:  # if language found, print it
            print "%s - %s:  %d" % (lang['code'], lang['name'].lower(), langSum)
    print "\n"
Example #3
0
def partFormat(searchPath, recursive, extension, keep, verbose):  # check subtitles encoding and format
    noFormat = 0
    srtFormat = 0
    samiFormat = 0
    dfxpFormat = 0
    kanal5Format = 0
    wrongEncoding = 0
    wrongNumbering = 0
    # wrongFormat = 0
    emptyEntry = 0
    subFiles = []

    subFiles = findSubFiles(searchPath, recursive, extension, subFiles, False, verbose)
    
    if subFiles:
        for myFile in subFiles:
            print "\n%s" % myFile
            encoding = checkCoding(myFile, verbose)  # check encoding
            if encoding == prefEncoding:
                print "--- Encoded in %s" % encoding  # correct encoding
            else:
                print "*** Encoded in %s" % encoding  # wrong encoding
                changeEncoding(myFile, encoding, keep, verbose)  # set to preferred encoding
                wrongEncoding += 1

            myFormat = checkFormat(myFile, verbose)  # check format
            if not myFormat:
                print "*** Could not detect format"
                noFormat += 1
            elif myFormat == "srt":
                print "--- Srt format"
                srtFormat += 1
                if emptyEntries(myFile, keep, verbose):  # look for empty entries, if so delete them
                    emptyEntry += 1
                if numbering(myFile, keep, verbose):  # check if numbering is correct, if not correct it
                    wrongNumbering += 1
            elif myFormat == "sami":
                print "*** Sami format"
                samiFormat += 1
                samiToSrt(myFile, keep, verbose)  # convert from SAMI to SRT
                if emptyEntries(myFile, keep, verbose):  # check for empty entries, if so delete them
                    emptyEntry += 1
                if numbering(myFile, keep, verbose):  # check if numbering is correct, if not correct it
                    wrongNumbering += 1
            elif myFormat == "dfxp":
                print "*** Dfxp format"
                dfxpFormat += 1
                dfxpToSrt(myFile, keep, verbose)  # convert from DFXP to SRT
            elif myFormat == "kanal5":
                print "*** Kanal5 format"
                kanal5Format += 1
                kanal5ToSrt(myFile, keep, verbose)  # convert from KANAL5 to SRT
                if emptyEntries(myFile, keep, verbose):  # check for empty entries, if so delete them
                    emptyEntry += 1
                if numbering(myFile, keep, verbose):  # check if numbering is correct, if not correct it
                    wrongNumbering += 1

    if noFormat + srtFormat + samiFormat + kanal5Format > 0:
        print "\nFormats:"
        if noFormat > 0:
            print "Not detected: %s" % noFormat
        if srtFormat > 0:
            print "srt: %s" % srtFormat
        if samiFormat > 0:
            print "sami: %s" % samiFormat
        if dfxpFormat > 0:
            print "dfxp: %s" % dfxpFormat
        if kanal5Format > 0:
            print "kanal5: %s" % kanal5Format
        print

    if wrongEncoding > 0:
        print "Files with wrong encoding: %s" % wrongEncoding
        print

    if emptyEntry > 0:
        print "Files with empty entries: %s" % emptyEntry
        print

    if wrongNumbering > 0:
        print "File with wrong numbering: %s" % wrongNumbering
        print
Example #4
0
def partCheck(recursive, searchPath, extension, findCode, verbose):  # check if language code set is correct
    langSums = []
    subsFound = []
    num = 0
    subFiles = []
    ask = False

    subFiles = findSubFiles(searchPath, recursive, extension, subFiles, findCode, verbose)

    if subFiles: 
        for myFile in subFiles:
            print "\n%s" % myFile
            existingCode = hasLangCode(os.path.join(searchPath, myFile))
            subsFound = foundLang(existingCode)
            if existingCode:
                
                if findCode != "all" and findCode != "pref" and findCode != "force":
                    if existingCode['code'] == str(findCode):
                        print "\n%s" % myFile
                        print (
                               "--- Has language code %s - %s"
                               % (existingCode['code'], existingCode['name'].lower())
                               )
                        checkedCode = checkLang(myFile, True)  # let detectlanguage.com see what language the file has
                        setCode = compareCodes(existingCode['code'],
                                               checkedCode, myFile, ask)  # compare existing and checked code
                        num += 1
                        langSums = foundLang(setCode)
                        
                elif findCode == "pref":
                    notPref = True
                    for lang in prefLangs:
                        if existingCode['code'] == lang:
                            notPref = False
                    if notPref:
                        print "\n%s" % myFile
                        print (
                               "--- Has language code %s - %s"
                               % (existingCode['code'], existingCode['name'].lower())
                               )
                        checkedCode = checkLang(myFile, True)  # let detectlanguage.com see what language the file has
                        setCode = compareCodes(existingCode['code'],
                                               checkedCode, myFile, ask)  # compare existing and checked code
                        num += 1
                        langSums = foundLang(setCode)
                        
                elif findCode == "all":
                    if existingCode:
                        print "\n%s" % myFile
                        print (
                               "--- Has language code %s - %s"
                               % (existingCode['code'], existingCode['name'].lower())
                               )
                        checkedCode = checkLang(myFile, 1)  # let detectlanguage.com see what language the file has
                        setCode = compareCodes(existingCode['code'],
                                               checkedCode, myFile, ask)  # compare existing and checked code
                        num += 1
                        langSums = foundLang(setCode)
                elif findCode == "force":
                    ask = True
                    if existingCode:
                        print "\n%s" % myFile
                        print (
                               "--- Has language code %s - %s"
                               % (existingCode['code'], existingCode['name'].lower())
                               )
                        checkedCode = checkLang(myFile, 1)  # let detectlanguage.com see what language the file has
                        setCode = compareCodes(existingCode['code'],
                                               checkedCode, myFile, ask)  # compare existing and checked code
                        num += 1
                        langSums = foundLang(setCode)
                    
            else:
                print "*** Has no language code"
    
    if subsFound:
        print "\nAll subtitles found:"
        for lang in languages:
            langSum = subsFound.count(lang['code'])
            if subsFound.count(lang['code']) > 0:
                print "%s - %s:  %d" % (lang['code'], lang['name'].lower(), langSum)
    
    if langSums:
        print "\nChecked:"
        for lang in languages:
            langSum = langSums.count(lang['code'])
            if langSums.count(lang['code']) > 0:
                print "%s - %s:  %d" % (lang['code'], lang['name'].lower(), langSum)
    print