Advertisement
iceman767

Week 5 Regex

Jan 11th, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.89 KB | None | 0 0
  1. import xbmc, xbmcgui, xbmcplugin
  2. import os, urllib, os
  3.  
  4. ######week 5 - IMPORT REGEX #######
  5. import re
  6.  
  7. ###### week 5 - NEW VARIABLES ###############
  8. HOME       = xbmc.translatePath('special://home/')
  9. regex1     = os.path.join(HOME, 'regex1.txt')
  10. #regex2     = os.path.join(HOME, 'regex2.txt')
  11.  
  12. #player  = xbmc.Player()
  13. video1  = 'https://archive.org/download/AppleAdEvery-jMs8KsU9dII/AppleAdEvery.m4v-jMs8KsU9dII.mp4'
  14. video2  = 'https://archive.org/download/WarningFromSpaceImproved1/Warning%20from%20Space%20Improved_1.mp4'
  15. video3  = 'https://archive.org/download/TheBrainThatWouldntDieTheatricalVersion82Min./TheBrainThatWouldntDie82Min._512kb.mp4'
  16. video4  = 'https://archive.org/download/TheChineseRoom/thechineseroom.mp4'
  17. trailer = 'https://archive.org/download/AppleAdEvery-jMs8KsU9dII/AppleAdEvery.m4v-jMs8KsU9dII.mp4'
  18. icon2   = 'http://icons.iconarchive.com/icons/chrisbanks2/cold-fusion-hd/128/assassins-creed-icon.png'
  19. icon3   = 'http://orig03.deviantart.net/56a6/f/2012/364/4/9/assasins_creed_3_icon___ico__by_backjumpone-d5pobei.png'
  20. icon4   = 'http://orig04.deviantart.net/a770/f/2012/060/0/f/syndicate_by_harrybana-d4qsqu1.png'
  21. ################################################
  22. # Initializw Plugin Directory Structure
  23. addon_handle = int(sys.argv[1])
  24. ################################################
  25.  
  26. #xbmcplugin.setContent(addon_handle, 'movies')
  27.  
  28. def addDir(url, title, icon):
  29.     li = xbmcgui.ListItem(title, iconImage=icon)
  30.     xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)
  31.  
  32. ###### week 5 - READ-FILE FUNCTION ##############
  33. def read_file(filename):
  34.     readfile = open(filename, 'r')
  35.     content  = readfile.read()
  36.     readfile.close()
  37.     return content
  38.  
  39. ###### week 5 - OPEN_URL FUNCTION ##############
  40. # #def Open_URL(url):
  41. #     req = urlib2.Request(url)
  42. #     req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 10.0; WOW64; Windows NT 5.1; en-GB; rv:1.9.0.3') AppleWebKit
  43. #     response    = urlib2.urlopen(req)
  44. #     link        = response.read()
  45. #     response.close()
  46. #     return link
  47.  
  48.  
  49. ####### Week 5- Main Regex Part 1 #############################
  50. content    = read_file(regex1)
  51. xbmc.log('#### CONTENTS: %s' % content)
  52. matches    = re.compile('name="(.+?)"').findall(content)
  53. for item in matches:
  54.     xbmc.log(item)
  55. #matches    = re.compile('name="(.+?)"').findall(content)
  56. #xbmc.log(str(matches))
  57.  
  58.  
  59.  
  60. #addDir(video1, 'Apple Add', 'C:\Users\Jose\Desktop\AC-Brotherhood.png')
  61. #addDir(video2, 'test 2', icon2)
  62. #addDir(video3, 'test 3', icon3)
  63. #addDir(video4, 'test 4', icon4)
  64.  
  65. ################################################
  66. # Close directory structure
  67. xbmcplugin.endOfDirectory(addon_handle)
  68. ################################################
  69.  
  70.  
  71. # dialog  = xbmcgui.Dialog()
  72. # player  = xbmc.Player()
  73. # video   = 'https://archive.org/download/AppleAdEvery-jMs8KsU9dII/AppleAdEvery.m4v-jMs8KsU9dII.mp4'
  74. # trailer = 'https://archive.org/download/AppleAdEvery-jMs8KsU9dII/AppleAdEvery.m4v-jMs8KsU9dII.mp4'
  75.  
  76. # choice = dialog.yesno('WATCH MOVIE?', 'Do you want to watch a movie', yeslabel='absolutely!!!', nolabel='WTF NO!!!')
  77. # if choice:
  78. #   choice = dialog.yesno('WATCH TRAILER OR MOVIE?', 'Do you want to watch the trailer or the movie', yeslabel='trailer', nolabel='movie')
  79. #   if choice == True:
  80. #       listitem = xbmcgui.ListItem ('trailer')
  81. #       player.play(trailer, listitem)
  82. #         else:
  83. #             listitem = xbmcgui.ListItem ('movie')
  84. #             player.play(video, listitem)
  85. # else:
  86. #   dialog.ok('CONTINUE','You pressed:', '[COLOR=yellow]stop[/COLOR]')
  87.  
  88. #   dialog.ok('CONTINUE','You pressed:', '[COLOR=dodgerblue]continue[/COLOR]', 'test line 3[CR]test line 4')
  89. # # Global variables
  90. # # variables assign different values to different items
  91.  
  92. # barroni   = 1
  93. # shan      = 'Two'
  94. # arb       = "three's"
  95. # houdin        = 'he says "hi guys"'
  96. # lee       = 'what\'s all \"this\" about?"
  97.  
  98. # def index():
  99. # xbmc.log('############# '+shan)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement