Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tvshow
- import config
- tvShowFile = tvshow.getTodaysFilename()
- time = tvshow.getTime()
- print ("Scanning file %s for %s" % (tvShowFile, time))
- row = tvshow.scanFileForTime(tvShowFile, time)
- if(row):
- urlColIndex = config.csvIndexes['url']
- streamUrl = row[urlColIndex]
- print("Executing app:" + config.apppath)
- print("URL:" + streamUrl)
- try:
- tvshow.show(streamUrl)
- except Exception as e:
- print ("Something went wrong:" + str(e))
- else:
- print("No show at time %s" % time)
- from datetime import datetime
- import config
- import csv
- import config
- from subprocess import call
- def getTodaysFilename():
- filename = datetime.now().strftime(config.fileTimeFormat)
- return config.filepath + "/" + filename + "." + config.extension
- def getTime():
- return datetime.now().strftime(config.hourMinuteFormat)
- def getFileContent(filename):
- lines = []
- with open(filename) as csvfile:
- csvContent = csv.reader(csvfile, delimiter = ',')
- for row in csvContent:
- lines.append(row)
- return lines
- def scanFileForTime(filename, time):
- timeColIndex = config.csvIndexes['time']
- content = getFileContent(filename)
- for row in content:
- if(row[timeColIndex] == time):
- return row
- def compileArguments(streamUrl):
- arguments = []
- arguments.append(config.apppath)
- arguments.append(streamUrl)
- for item in config.appArguments:
- arguments.append(item)
- return arguments
- def show(streamUrl):
- arguments = compileArguments(streamUrl)
- call(arguments)
- apppath = '/Applications/VLC.app/Contents/MacOS/VLC'
- filepath = '/Users/Shared/tvshow'
- fileTimeFormat = "%Y_%m_%d"
- hourMinuteFormat = "%H:%M"
- extension = 'csv'
- csvIndexes = dict(
- time = 0,
- title = 1,
- url = 2
- )
- appArguments = [
- '--fullscreen',
- '--no-loop',
- '--play-and-exit'
- ]
- "19:47","Big Buck Bunny","http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4"
Add Comment
Please, Sign In to add comment