Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import xbmc, xbmcgui, xbmcplugin
- import os, urllib, os
- ######week 5 - IMPORT REGEX #######
- import re
- ###### week 5 - NEW VARIABLES ###############
- HOME = xbmc.translatePath('special://home/')
- regex1 = os.path.join(HOME, 'regex1.txt')
- #regex2 = os.path.join(HOME, 'regex2.txt')
- #player = xbmc.Player()
- video1 = 'https://archive.org/download/AppleAdEvery-jMs8KsU9dII/AppleAdEvery.m4v-jMs8KsU9dII.mp4'
- video2 = 'https://archive.org/download/WarningFromSpaceImproved1/Warning%20from%20Space%20Improved_1.mp4'
- video3 = 'https://archive.org/download/TheBrainThatWouldntDieTheatricalVersion82Min./TheBrainThatWouldntDie82Min._512kb.mp4'
- video4 = 'https://archive.org/download/TheChineseRoom/thechineseroom.mp4'
- trailer = 'https://archive.org/download/AppleAdEvery-jMs8KsU9dII/AppleAdEvery.m4v-jMs8KsU9dII.mp4'
- icon2 = 'http://icons.iconarchive.com/icons/chrisbanks2/cold-fusion-hd/128/assassins-creed-icon.png'
- icon3 = 'http://orig03.deviantart.net/56a6/f/2012/364/4/9/assasins_creed_3_icon___ico__by_backjumpone-d5pobei.png'
- icon4 = 'http://orig04.deviantart.net/a770/f/2012/060/0/f/syndicate_by_harrybana-d4qsqu1.png'
- ################################################
- # Initializw Plugin Directory Structure
- addon_handle = int(sys.argv[1])
- ################################################
- #xbmcplugin.setContent(addon_handle, 'movies')
- def addDir(url, title, icon):
- li = xbmcgui.ListItem(title, iconImage=icon)
- xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)
- ###### week 5 - READ-FILE FUNCTION ##############
- def read_file(filename):
- readfile = open(filename, 'r')
- content = readfile.read()
- readfile.close()
- return content
- ###### week 5 - OPEN_URL FUNCTION ##############
- # #def Open_URL(url):
- # req = urlib2.Request(url)
- # 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
- # response = urlib2.urlopen(req)
- # link = response.read()
- # response.close()
- # return link
- ####### Week 5- Main Regex Part 1 #############################
- content = read_file(regex1)
- xbmc.log('#### CONTENTS: %s' % content)
- matches = re.compile('name="(.+?)"').findall(content)
- for item in matches:
- xbmc.log(item)
- #matches = re.compile('name="(.+?)"').findall(content)
- #xbmc.log(str(matches))
- #addDir(video1, 'Apple Add', 'C:\Users\Jose\Desktop\AC-Brotherhood.png')
- #addDir(video2, 'test 2', icon2)
- #addDir(video3, 'test 3', icon3)
- #addDir(video4, 'test 4', icon4)
- ################################################
- # Close directory structure
- xbmcplugin.endOfDirectory(addon_handle)
- ################################################
- # dialog = xbmcgui.Dialog()
- # player = xbmc.Player()
- # video = 'https://archive.org/download/AppleAdEvery-jMs8KsU9dII/AppleAdEvery.m4v-jMs8KsU9dII.mp4'
- # trailer = 'https://archive.org/download/AppleAdEvery-jMs8KsU9dII/AppleAdEvery.m4v-jMs8KsU9dII.mp4'
- # choice = dialog.yesno('WATCH MOVIE?', 'Do you want to watch a movie', yeslabel='absolutely!!!', nolabel='WTF NO!!!')
- # if choice:
- # choice = dialog.yesno('WATCH TRAILER OR MOVIE?', 'Do you want to watch the trailer or the movie', yeslabel='trailer', nolabel='movie')
- # if choice == True:
- # listitem = xbmcgui.ListItem ('trailer')
- # player.play(trailer, listitem)
- # else:
- # listitem = xbmcgui.ListItem ('movie')
- # player.play(video, listitem)
- # else:
- # dialog.ok('CONTINUE','You pressed:', '[COLOR=yellow]stop[/COLOR]')
- # dialog.ok('CONTINUE','You pressed:', '[COLOR=dodgerblue]continue[/COLOR]', 'test line 3[CR]test line 4')
- # # Global variables
- # # variables assign different values to different items
- # barroni = 1
- # shan = 'Two'
- # arb = "three's"
- # houdin = 'he says "hi guys"'
- # lee = 'what\'s all \"this\" about?"
- # def index():
- # xbmc.log('############# '+shan)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement