Guest User

Untitled

a guest
Jul 22nd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. import tvshow
  2. import config
  3.  
  4. tvShowFile = tvshow.getTodaysFilename()
  5. time = tvshow.getTime()
  6. print ("Scanning file %s for %s" % (tvShowFile, time))
  7. row = tvshow.scanFileForTime(tvShowFile, time)
  8.  
  9. if(row):
  10. urlColIndex = config.csvIndexes['url']
  11. streamUrl = row[urlColIndex]
  12. print("Executing app:" + config.apppath)
  13. print("URL:" + streamUrl)
  14. try:
  15. tvshow.show(streamUrl)
  16. except Exception as e:
  17. print ("Something went wrong:" + str(e))
  18. else:
  19. print("No show at time %s" % time)
  20.  
  21. from datetime import datetime
  22. import config
  23. import csv
  24. import config
  25. from subprocess import call
  26.  
  27. def getTodaysFilename():
  28. filename = datetime.now().strftime(config.fileTimeFormat)
  29. return config.filepath + "/" + filename + "." + config.extension
  30.  
  31. def getTime():
  32. return datetime.now().strftime(config.hourMinuteFormat)
  33.  
  34. def getFileContent(filename):
  35. lines = []
  36. with open(filename) as csvfile:
  37. csvContent = csv.reader(csvfile, delimiter = ',')
  38. for row in csvContent:
  39. lines.append(row)
  40. return lines
  41.  
  42. def scanFileForTime(filename, time):
  43. timeColIndex = config.csvIndexes['time']
  44. content = getFileContent(filename)
  45. for row in content:
  46. if(row[timeColIndex] == time):
  47. return row
  48.  
  49. def compileArguments(streamUrl):
  50. arguments = []
  51. arguments.append(config.apppath)
  52. arguments.append(streamUrl)
  53. for item in config.appArguments:
  54. arguments.append(item)
  55. return arguments
  56.  
  57. def show(streamUrl):
  58. arguments = compileArguments(streamUrl)
  59. call(arguments)
  60.  
  61. apppath = '/Applications/VLC.app/Contents/MacOS/VLC'
  62. filepath = '/Users/Shared/tvshow'
  63. fileTimeFormat = "%Y_%m_%d"
  64. hourMinuteFormat = "%H:%M"
  65. extension = 'csv'
  66. csvIndexes = dict(
  67. time = 0,
  68. title = 1,
  69. url = 2
  70. )
  71. appArguments = [
  72. '--fullscreen',
  73. '--no-loop',
  74. '--play-and-exit'
  75. ]
  76.  
  77. "19:47","Big Buck Bunny","http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4"
Add Comment
Please, Sign In to add comment