Did some formatting changes to make it more readable

This commit is contained in:
2017-03-05 00:50:08 +01:00
parent 9a04584b02
commit 4d854a0f80

View File

@@ -3,7 +3,7 @@
# @Author: KevinMidboe
# @Date: 2017-03-04 16:50:09
# @Last Modified by: KevinMidboe
# @Last Modified time: 2017-03-04 22:15:21
# @Last Modified time: 2017-03-05 00:49:03
import os, sqlite3, re
from fuzzywuzzy import process
@@ -15,9 +15,6 @@ dbPath = 'shows.db'
mediaExtensions = ['mkv', 'mp4', 'avi']
subExtensions = ['srt']
def XOR(list1, list2):
return set(list1) ^ set(list2)
def getFuzzyName(query):
return process.extractOne(query, getShowNames().keys())
@@ -50,12 +47,18 @@ def getShowNames():
conn.close()
return returnList
def XOR(list1, list2):
return set(list1) ^ set(list2)
def getNewFolderContents():
showNames = getShowNames().keys()
folderContents = filter( lambda f: not f.startswith('.'), os.listdir(showDir))
return XOR(folderContents, showNames)
def checkForSingleEpisodes(folderItem):
showName, hit = getFuzzyName(folderItem)
episodeMatch = re.findall(re.sub(' ', '.', showName)+'\.S[0-9]{1,2}E[0-9]{1,2}\.', folderItem)
@@ -63,6 +66,8 @@ def checkForSingleEpisodes(folderItem):
if episodeMatch:
return True
def getByIdentifier(folderItem, identifier):
itemMatch = re.findall(identifier + '[0-9]{1,2}', folderItem)
item = re.sub(identifier, '', itemMatch[0])
@@ -84,7 +89,6 @@ def getItemChildren(folder):
return media_items, subtitles, trash
def getEpisodeInfo(folderItem):
showName, hit = getFuzzyName(folderItem)
season = getByIdentifier(folderItem, 'S')
@@ -105,6 +109,7 @@ def getEpisodeInfo(folderItem):
return episodeInfo
def main():
for item in getNewFolderContents():
if checkForSingleEpisodes(item):