Added a global function that runs all needed functions
This commit is contained in:
14
findStray.py
14
findStray.py
@@ -3,7 +3,7 @@
|
||||
# @Author: KevinMidboe
|
||||
# @Date: 2017-03-04 16:50:09
|
||||
# @Last Modified by: KevinMidboe
|
||||
# @Last Modified time: 2017-03-05 14:48:17
|
||||
# @Last Modified time: 2017-03-05 15:53:19
|
||||
|
||||
import os, sqlite3, re, json
|
||||
from fuzzywuzzy import process
|
||||
@@ -105,7 +105,8 @@ def getEpisodeInfo(folderItem):
|
||||
'subtitles': subtitles,
|
||||
'trash': trash,
|
||||
'tweet_id': 'NULL',
|
||||
'verified': '0'}
|
||||
'verified': '0',
|
||||
'moved': '0'}
|
||||
|
||||
|
||||
addToDB(episodeInfo)
|
||||
@@ -126,11 +127,12 @@ def addToDB(episodeInfo):
|
||||
trash = json.dumps(episodeInfo['trash'])
|
||||
tweet_id = episodeInfo['tweet_id'] + ','
|
||||
verified = episodeInfo['verified']
|
||||
moved = episodeInfo['moved']
|
||||
|
||||
print((media_items))
|
||||
try:
|
||||
c.execute('INSERT INTO stray_episodes VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', [original,\
|
||||
full_path, name, season, episode, media_items, subtitles, trash, None, verified])
|
||||
c.execute('INSERT INTO stray_episodes VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', [original,\
|
||||
full_path, name, season, episode, media_items, subtitles, trash, None, verified, moved])
|
||||
|
||||
except sqlite3.IntegrityError:
|
||||
print('Episode already registered')
|
||||
@@ -138,11 +140,11 @@ def addToDB(episodeInfo):
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
def main():
|
||||
def findStray():
|
||||
for item in getNewFolderContents():
|
||||
if checkForSingleEpisodes(item):
|
||||
pprint(getEpisodeInfo(item))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
findStray()
|
||||
@@ -3,7 +3,7 @@
|
||||
# @Author: KevinMidboe
|
||||
# @Date: 2017-03-05 13:52:45
|
||||
# @Last Modified by: KevinMidboe
|
||||
# @Last Modified time: 2017-03-05 15:22:30
|
||||
# @Last Modified time: 2017-03-05 15:53:04
|
||||
|
||||
import sqlite3, json, os
|
||||
from re import sub
|
||||
@@ -14,7 +14,7 @@ def unpackEpisodes():
|
||||
conn = sqlite3.connect(dbPath)
|
||||
c = conn.cursor()
|
||||
|
||||
cursor = c.execute('SELECT * FROM stray_episodes WHERE verified = 1')
|
||||
cursor = c.execute('SELECT * FROM stray_episodes WHERE verified = 1 AND moved = 0')
|
||||
episodeList = []
|
||||
for row in c.fetchall():
|
||||
columnNames = [description[0] for description in cursor.description]
|
||||
@@ -50,7 +50,7 @@ def newnameMediaitems(media_items):
|
||||
|
||||
returnList = []
|
||||
for item in media_items:
|
||||
returnList.append([item[0], sub(item[1], '', item[0])])
|
||||
returnList.append([item[0], item[0].replace(item[1], '')])
|
||||
|
||||
return returnList
|
||||
|
||||
@@ -59,11 +59,20 @@ def newnameSubtitles(subtitles):
|
||||
|
||||
returnList = []
|
||||
for item in subtitles:
|
||||
returnList.append([item[0], sub(item[1], '.' + item[2], item[0])])
|
||||
returnList.append([item[0], item[0].replace(item[1], '.' + item[2])])
|
||||
|
||||
return returnList
|
||||
|
||||
|
||||
def updateMovedStatus(episodeDict):
|
||||
conn = sqlite3.connect(dbPath)
|
||||
c = conn.cursor()
|
||||
|
||||
c.execute('UPDATE stray_episodes SET moved = 1 WHERE original is "' + episodeDict['original'] + '"')
|
||||
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
def moveFiles(episode):
|
||||
showDir = '/Volumes/media/tv/'
|
||||
episodeFormat = '%s S%sE%s/'% (episode['name'], episode['season'], episode['episode'])
|
||||
@@ -80,6 +89,8 @@ def moveFiles(episode):
|
||||
print(showDir + episode['original'] + '/' + item[0])
|
||||
print(showDir + seasonFormat + episodeFormat + item[1] + '\n')
|
||||
|
||||
updateMovedStatus(episode)
|
||||
|
||||
|
||||
|
||||
def findVerified():
|
||||
@@ -88,12 +99,8 @@ def findVerified():
|
||||
for episode in episodes:
|
||||
createFolders(episode)
|
||||
moveFiles(episode)
|
||||
|
||||
# for item in c.fetchall():
|
||||
# print(item)
|
||||
|
||||
def main():
|
||||
findVerified()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
findVerified()
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# @Author: KevinMidboe
|
||||
# @Date: 2017-03-04 16:50:09
|
||||
# @Last Modified by: KevinMidboe
|
||||
# @Last Modified time: 2017-03-05 13:07:08
|
||||
# @Last Modified time: 2017-03-05 15:54:31
|
||||
|
||||
import tweepy, sqlite3
|
||||
from pasteee import Paste
|
||||
@@ -72,7 +72,7 @@ def tweetEpisode(episode):
|
||||
updateTweetID(episode, tweet_id)
|
||||
|
||||
|
||||
def tweetNewEpisodes():
|
||||
def lookForNewEpisodes():
|
||||
conn = sqlite3.connect(dbPath)
|
||||
c = conn.cursor()
|
||||
|
||||
@@ -125,9 +125,10 @@ def checkForReply():
|
||||
getReply(tweet)
|
||||
|
||||
|
||||
def main():
|
||||
tweetNewEpisodes()
|
||||
def tweetNewEpisodes():
|
||||
lookForNewEpisodes()
|
||||
checkForReply()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
tweetNewEpisodes()
|
||||
|
||||
Reference in New Issue
Block a user