/addons/plugin.video.animecrazy/default.py
Python | 1249 lines | 1238 code | 8 blank | 3 comment | 7 complexity | 5cc93072a28e4be3859fc15e43269ac1 MD5 | raw file
Possible License(s): GPL-3.0
Large files files are truncated, but you can click here to view the full file
- import urllib,urllib2,re,sys,xbmcplugin,xbmcgui,httplib
- import cookielib,os,string,cookielib,StringIO
- import os,time,base64,logging
- import xbmcaddon
- from datetime import datetime
- try:
- import json
- except ImportError:
- import simplejson as json
-
- #animecrazy
- dc=xbmcaddon.Addon(id='plugin.video.animecrazy')
- addonPath=os.getcwd()
- artPath=addonPath+'/resources/art'
- def HOME():
- icon = os.path.join(xbmc.translatePath( addonPath ), 'icon.png')
-
- #addDir('Index','http://www.animecrazy.net/anime-index/',2,icon)
- addDir('Genres','http://www.animecrazy.net/anime-index/',3,icon)
- addDir('A-Z list','http://www.animecrazy.net/anime-index/',4,icon)
- addDir('Most Popular','http://www.animecrazy.net/most-popular/',5,icon)
- addDir('Most Recent','http://www.animecrazy.net/most-recent/',6,icon)
- searchIcon = os.path.join(xbmc.translatePath( artPath ), 'search-icon.png')
- addDir('Search','http://www.animecrazy.net/anime-index/',7,searchIcon)
- #addDir('NEW ADD-ON :: VEOH [I]beta[/I]', 'http://www.animecrazy.net/', 50, os.path.join(xbmc.translatePath( artPath ), "AJ.png"))
- def WHAT_IS_COMING(url):
- d = xbmcgui.Dialog()
- d.ok('NEW FEATURE: VEOH Video Support ADDED', 'DONATE today: \n[B]http://code.google.com/p/apple-tv2-xbmc/[/B]')
-
- def INDEX(url):
- url = 'http://www.animecrazy.net/anime-index/'
- req = urllib2.Request(url)
- req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
- response = urllib2.urlopen(req)
- link=response.read()
- response.close()
- link = ''.join(link.splitlines()).replace('\t','')
- match=re.compile('<ul class="truindexlist">(.+?)</ul>').findall(link)
- if(len(match) >= 1):
- quickLinks=re.compile('<li><a href="#(.+?)">(.+?)</a></li>').findall(match[0])
- for quickLink, quickLinkName in quickLinks:
- match = re.compile('<h2 style="padding: 20px 10px 10px 5px;border-top: 4px solid rgb\(0, 0, 0\); background-color: rgb\(12, 148, 158\); color: rgb\(255, 255, 255\);clear:both">(.+?)<a name="'+quickLink+'"></a></h2>(.+?)(</div>|<h2)').findall(link)
- addDir(quickLinkName,match[0][1],21,'')
- def INDEX_A_Z(url):
- matches = re.compile('<ul class="truindexlist"><p class="truindexlistheader">(.+?)</p>(.+?)</ul>').findall(url)
- for char, videoList in matches:
- addDir(char,videoList,22,'')
- def INDEX_A_Z_VIDEOS(url):
- videoLinks = re.compile('<li><a href="/(.+?)">(.+?)</li>').findall(url)
- xbmc.executebuiltin("XBMC.Notification(Please Wait!,Retrieving video info and image,5000)")
- for videoLink, videoName in videoLinks:
- addVideoInfo_Image('http://www.animecrazy.net/' + videoLink, videoName)
-
- def GENRES(url):
- url = 'http://www.animecrazy.net/anime-index/'
- req = urllib2.Request(url)
- req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
- response = urllib2.urlopen(req)
- link=response.read()
- response.close()
- link = ''.join(link.splitlines()).replace('\t','')
-
- match=re.compile('<strong>Genre:</strong>(.+?)</div>').findall(link)
- if(len(match) >= 1):
- genres=re.compile('<a href="/(.+?)">(.+?)</a>').findall(match[0])
- for genreLink, genreName in genres:
- addDir(genreName,'http://www.animecrazy.net/'+genreLink,31,'')
- def GENRE_VIDEOS(url):
- Video_List_Searched(url)
- def A_Z_LIST(url):
- addDir('A','http://www.animecrazy.net/alpha-a/',41,'')
- addDir('B','http://www.animecrazy.net/alpha-b/',41,'')
- addDir('C','http://www.animecrazy.net/alpha-c/',41,'')
- addDir('D','http://www.animecrazy.net/alpha-d/',41,'')
- addDir('E','http://www.animecrazy.net/alpha-e/',41,'')
- addDir('F','http://www.animecrazy.net/alpha-f/',41,'')
- addDir('G','http://www.animecrazy.net/alpha-g/',41,'')
- addDir('H','http://www.animecrazy.net/alpha-h/',41,'')
- addDir('I','http://www.animecrazy.net/alpha-i/',41,'')
- addDir('J','http://www.animecrazy.net/alpha-j/',41,'')
- addDir('K','http://www.animecrazy.net/alpha-k/',41,'')
- addDir('L','http://www.animecrazy.net/alpha-l/',41,'')
- addDir('M','http://www.animecrazy.net/alpha-m/',41,'')
- addDir('N','http://www.animecrazy.net/alpha-n/',41,'')
- addDir('O','http://www.animecrazy.net/alpha-o/',41,'')
- addDir('P','http://www.animecrazy.net/alpha-p/',41,'')
- addDir('Q','http://www.animecrazy.net/alpha-q/',41,'')
- addDir('R','http://www.animecrazy.net/alpha-r/',41,'')
- addDir('S','http://www.animecrazy.net/alpha-s/',41,'')
- addDir('Q','http://www.animecrazy.net/alpha-q/',41,'')
- addDir('U','http://www.animecrazy.net/alpha-u/',41,'')
- addDir('V','http://www.animecrazy.net/alpha-v/',41,'')
- addDir('W','http://www.animecrazy.net/alpha-w/',41,'')
- addDir('X','http://www.animecrazy.net/alpha-x/',41,'')
- addDir('Y','http://www.animecrazy.net/alpha-y/',41,'')
- addDir('Z','http://www.animecrazy.net/alpha-z/',41,'')
-
- def A_Z_LIST_VIDEOS(url):
- Video_List_And_Pagination(url)
-
- def MOST_POPULAR(url):
- Video_List_And_Pagination(url)
-
- def MOST_RECENT(url):
- Video_List_And_Pagination(url)
-
- def SEARCH(url):
- keyb = xbmc.Keyboard('', 'Enter search text')
- keyb.doModal()
- searchText = ''
- if (keyb.isConfirmed()):
- searchText = urllib.quote_plus(keyb.getText())
- url = 'http://www.animecrazy.net/search/'+searchText
- Video_List_Searched(url)
- def PAGES(url):
- Video_List_And_Pagination(url)
-
- def Video_List_Searched(url):
- req = urllib2.Request(url)
- req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
- response = urllib2.urlopen(req)
- link=response.read()
- response.close()
- link = ''.join(link.splitlines()).replace('\t','')
- match=re.compile('<div class="top4">(.+?)<div class="clear"> </div></div>').findall(link)
- if(len(match) >= 1):
- videoInfo=re.compile('<a href="/(.+?)"><p>(.+?)</p><img src="(.+?)" alt="" width="150px" /></a>').findall(match[0])
- xbmc.executebuiltin("XBMC.Notification(Please Wait!,Retrieving video info and image,5000)")
- for videoLink, videoName, imgSrc in videoInfo:
- addVideoInfo_Image('http://www.animecrazy.net/' + videoLink, videoName)
-
- match=re.compile('<div class="moreActionResults contentModule">(.+?)</div><div class="clear"></div></div>').findall(link)
- if(len(match) >= 1):
- videoInfo=re.compile('<p class="longTitle floatLeft"><a href="/(.+?)">(.+?)</p>').findall(match[0])
- for videoLink, videoName in videoInfo:
- addVideoInfo_Image('http://www.animecrazy.net/' + videoLink, videoName)
-
- def Video_List_And_Pagination(url):
- req = urllib2.Request(url)
- req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
- response = urllib2.urlopen(req)
- link=response.read()
- response.close()
- link = ''.join(link.splitlines()).replace('\t','')
- match=re.compile('<h1><a href="/(.+?)">(.+?)</a></h1>').findall(link)
- xbmc.executebuiltin("XBMC.Notification(Please Wait!,Retrieving video info and image,5000)")
- for videoLink, videoName in match:
- addVideoInfo_Image('http://www.animecrazy.net/' + videoLink, videoName)
- match=re.compile('<div class="paginationDiv">(.+?)<div class="clear"></div></div>').findall(link)
- if(len(match) >= 1):
- pages=re.compile('<a href="(.+?)">(.+?)</a>').findall(match[0])
- for pageUrl, page in pages:
- pageNbr = page.replace('‹','<').replace('›','>').replace('>','>').replace('<','<')
- icon = ''
- dirName = ''
- if(pageNbr == '<'):
- dirName = '< PREVIOUS Page'
- icon = os.path.join(xbmc.translatePath( artPath ), 'prev-icon.png')
- elif(pageNbr == '>'):
- dirName = 'NEXT Page >'
- icon = os.path.join(xbmc.translatePath( artPath ), 'next-icon.png')
- elif(pageNbr == '< First'):
- dirName = '< FIRST Page'
- icon = os.path.join(xbmc.translatePath( artPath ), 'first-icon.png')
- elif(pageNbr == 'Last >'):
- dirName = 'LAST Page >'
- icon = os.path.join(xbmc.translatePath( artPath ), 'last-icon.png')
- else:
- dirName = 'TO Page: '+pageNbr
- addDir(dirName,pageUrl,8,icon)
- def addVideoInfo_Image(url, name):
- try:
- print url
- req = urllib2.Request(url)
- req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
- response = urllib2.urlopen(req)
- link=response.read()
- response.close()
- link = ''.join(link.splitlines()).replace('\t','')
- imgUrl=re.compile('<img src="(.+?)" width="150px" alt="(.+?)Image" />').findall(link)[0][0]
- match=re.compile('<div class="text floatLeft">(.+?)</div>').findall(link)
- videoName=re.compile('<h1>(.+?)</h1>').findall(match[0])
- ranks=re.compile('<span class="position">(.+?)</span><br /><span class="totalNr">of (.+?)</span>').findall(match[0])
- videoTitle = videoName[0] + ' (Rank: ' + ranks[0][0] + ' of ' + ranks[0][1] +')'
- videoEpisodesUrl = url[0:len(url)-1] + '-episode-list/'
- addDir(videoTitle,videoEpisodesUrl,9,imgUrl)
- except httplib.IncompleteRead:
- xbmc.executebuiltin("XBMC.Notification(Skipped: "+name+",Continue retrieving video info and image about next video,5000)")
- pass
- def EPISODES_OR_MOVIE(url):
- url = url.replace('-anime-episode-list/', '-episode-list/')
- url = url.replace('-movie-episode-list/', '-movie/')
- req = urllib2.Request(url)
- req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
- response = urllib2.urlopen(req)
- link=response.read()
- response.close()
- link = ''.join(link.splitlines()).replace('\t','')
- if re.search('404 Page Not Found', link):
- d = xbmcgui.Dialog()
- d.ok('NO episodes found','There are no episodes added for this drama.','Be the first to add episode, visit www.dramacrazy.net now','')
- return
- imgUrl = ''
- try:
- imgUrl='http://www.animecrazy.net/' + re.compile('<img src="/(.+?)" width="150px" alt="(.+?)Image" />').findall(link)[0][0]
- except:
- try:
- imgUrl='http://i.animecrazy.net/' + re.compile('<img src="http://i.animecrazy.net/(.+?)" width="150px" alt="(.+?)Image">').findall(link)[0][0]
- except:
- imgUrl = ''
-
- episodes=re.compile('<a class="floatLeft" id="episode(.+?)" href="/(.+?)">(.+?)</a> <p class="floatRight"> (.+?) </p>').findall(link)
-
- if(len(episodes) > 0):
- for episodeId, episodeUrl, episodeName, episodeAddedDate in episodes:
- episodeTitle = unescape(episodeName) +' (Added on: '+episodeAddedDate+')'
- addDir(episodeTitle,'http://www.animecrazy.net/' + episodeUrl,10,imgUrl)
- else:
- PARTS('http://www.animecrazy.net/' + re.compile('<a class="floatLeft" href="/(.+?)">(.+?)</a>').findall(link)[0][0])
-
-
- def PARTS(url):
- req = urllib2.Request(url)
- req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
- response = urllib2.urlopen(req)
- link=response.read()
- response.close()
- link = ''.join(link.splitlines()).replace('\t','').replace('\'','"')
- streamingLinksModule=re.compile('<!-- Small Div alternate streaming mirros -->(.+?)<!--End of alternate streaming mirrors -->').findall(link)
- streamingLinks=re.compile('<div class="row">(.+?)<div class="clear"></div></div>').findall(streamingLinksModule[0])
- for stramingLinkRow in streamingLinks:
- parts = re.compile('<a (.+?) onclick="return encLink\("/(.+?)"\);" (.+?)>').findall(stramingLinkRow.replace(')"',');"'))
- streamingName = re.compile('Watch(.+?)\)').findall(stramingLinkRow)
- streamTypeName = 'Watch' + streamingName[0] + ')'
- if re.search('\(Wat\)', streamTypeName):
- continue
-
- matchCount = len(parts)
- if(matchCount > 1):
- i = 0
- playList = ''
- for temp1, partLink, temp2 in parts:
- i = i + 1
- print ' - PART: '+str(i)+' PART link = '+partLink
- partName = streamTypeName + ' - PART: '+str(i)
- addPlayableLink(partName,'http://www.animecrazy.net/' + partLink,16,'')
- playList = playList + 'http://www.animecrazy.net/' + partLink
- if(i < matchCount):
- playList = playList + ':;'
- addPlayListLink('------------->[B]Direct PLAY[/B]<------------- [I]Playlist of above ' + str(matchCount) + ' videos[/I]',playList,12,'')
- else:
- addPlayableLink('[B]SINGLE LINK[/B] ' + streamTypeName,'http://www.animecrazy.net/' + parts[0][1],16,'')
- def PLAYLIST_VIDEOLINKS(url,name):
- ok=True
- playList = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
- playList.clear()
- #time.sleep(2)
- links = url.split(':;')
- pDialog = xbmcgui.DialogProgress()
- ret = pDialog.create('Loading playlist...')
- totalLinks = len(links)
- loadedLinks = 0
- remaining_display = 'Videos loaded :: [B]'+str(loadedLinks)+' / '+str(totalLinks)+'[/B] into XBMC player playlist.'
- pDialog.update(0,'Please wait for the process to retrieve video link.',remaining_display)
-
- for videoLink in links:
- loadVideos(videoLink,name,True,True)
- loadedLinks = loadedLinks + 1
- percent = (loadedLinks * 100)/totalLinks
- #print percent
- remaining_display = 'Videos loaded :: [B]'+str(loadedLinks)+' / '+str(totalLinks)+'[/B] into XBMC player playlist.'
- pDialog.update(percent,'Please wait for the process to retrieve video link.',remaining_display)
- if (pDialog.iscanceled()):
- return False
- xbmcPlayer = xbmc.Player()
- xbmcPlayer.play(playList)
- if not xbmcPlayer.isPlayingVideo():
- d = xbmcgui.Dialog()
- d.ok('INVALID VIDEO PLAYLIST', 'The playlist videos were removed due to copyright issue.','Check other links.')
- return ok
- def LOAD_AND_PLAY_VIDEO(url,name):
- xbmc.executebuiltin("XBMC.Notification(PLease Wait!,Loading video link into XBMC Media Player,5000)")
- ok=True
- print url
- videoUrl = loadVideos(url,name,True,False)
- if videoUrl == None:
- d = xbmcgui.Dialog()
- d.ok('NO VIDEO FOUND', 'This video was removed due to copyright issue.','Check other links.')
- return False
- elif videoUrl == 'ERROR':
- return False
- xbmcPlayer = xbmc.Player()
- xbmcPlayer.play(videoUrl)
- return ok
- def VIDEOLINKS(url,name):
- loadVideos(url,name,False,False)
- def loadVideos(url,name,isRequestForURL,isRequestForPlaylist):
- req = urllib2.Request(url)
- req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
- response = urllib2.urlopen(req)
- link=response.read()
- response.close()
- link = ''.join(link.splitlines()).replace('\t','').replace('\'','"')
- streamingPlayer = re.compile('document.write\(unescape\("(.+?)"\)\);').findall(link)
- if(len(streamingPlayer) == 0):
-
- episodeContent = re.compile('<div class="episodeContent">(.+?)</div>').findall(link)[0]
- url = re.compile('src="(.+?)"').findall(episodeContent)[0]
- req = urllib2.Request(url)
- req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
- response = urllib2.urlopen(req)
- link=response.read()
- response.close()
- link = ''.join(link.splitlines()).replace('\t','').replace('\'','"')
- streamingPlayer = re.compile('document.write\(unescape\("(.+?)"\)\);').findall(link)
- if(len(streamingPlayer) == 0):
- streamingPlayer = [ urllib.quote_plus(link) ]
-
- frame = urllib.unquote_plus(streamingPlayer[0]).replace('\'','"').replace(' =','=').replace('= ','=')
- videoUrl = re.compile('config=(.+?)&').findall(frame)
- if(len(videoUrl) == 0):
- videoUrl = re.compile('data="(.+?)"').findall(frame)
- if(len(videoUrl) == 0):
- videoUrl = re.compile('file=(.+?)&autostart').findall(frame)
- if(len(videoUrl) == 0):
- videoUrl = re.compile('href="(.+?)"').findall(frame)
- if(len(videoUrl) == 0):
- videoUrl = re.compile('src="(.+?)"').findall(frame)
- url = videoUrl[0] + '&AJ;'
-
- print 'VIDEO LINK = '+url
-
- #ANIMECRAZY
- try:
- match=re.compile('http://www.animecrazy.net/(.+?)&AJ;').findall(url)[0]
- req = urllib2.Request('http://www.animecrazy.net/'+match)
- req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
- response = urllib2.urlopen(req)
- link=urllib.unquote(response.read())
- response.close()
- link = ''.join(link.splitlines()).replace('\'','"')
-
- url = re.compile('<iframe src ="(.+?)"').findall(link)[0] + '&AJ;'
- print 'NEW url = '+url
-
- req = urllib2.Request(url)
- req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
- response = urllib2.urlopen(req)
- link=urllib.unquote(response.read())
- response.close()
- link = ''.join(link.splitlines()).replace('\'','"')
- match = re.compile('"file": "(.+?)"').findall(link)
- if len(match) == 0:
- match = re.compile('<file>(.+?)</file>').findall(link)
- videoUrl = match[0]
- imgUrl = ''
- videoTitle = name
- if(isRequestForURL):
- if(isRequestForPlaylist):
- liz = xbmcgui.ListItem(videoTitle, thumbnailImage=imgUrl)
- playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
- playlist.add(url=videoUrl, listitem=liz)
- else:
- return videoUrl
- else:
- addLink ('[B]PLAY VIDEO[/B]: '+videoTitle,videoUrl,imgUrl)
-
-
- except: pass
-
-
- #DRAMACRAZY
- try:
- match=re.compile('http://www.dramacrazy.net/(.+?)&AJ;').findall(url)[0]
- req = urllib2.Request('http://www.dramacrazy.net/'+match)
- req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
- response = urllib2.urlopen(req)
- link=urllib.unquote(response.read())
- response.close()
- link = ''.join(link.splitlines()).replace('\'','"')
-
- match = re.compile('<iframe src ="(.+?)"').findall(link)
- if len(match) > 0:
- frameUrl = match[0]
- req = urllib2.Request(frameUrl)
- req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
- response = urllib2.urlopen(req)
- link=urllib.unquote(response.read())
- response.close()
- link = ''.join(link.splitlines()).replace('\'','"')
- match = re.compile('"file": "(.+?)"').findall(link)
- if len(match) == 0:
- match = re.compile('<file>(.+?)</file>').findall(link)
- videoUrl = match[0]
- imgUrl = ''
- videoTitle = name
- if(isRequestForURL):
- if(isRequestForPlaylist):
- liz = xbmcgui.ListItem(videoTitle, thumbnailImage=imgUrl)
- playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
- playlist.add(url=videoUrl, listitem=liz)
- else:
- return videoUrl
- else:
- addLink ('[B]PLAY VIDEO[/B]: '+videoTitle,videoUrl,imgUrl)
-
- except: pass
-
- #Gamedorm.net
- try:
- match=re.compile('gamedorm.net/(.+?)&AJ;').findall(url)[0]
- req = urllib2.Request('http://gamedorm.net/'+match)
- req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
- response = urllib2.urlopen(req)
- link=urllib.unquote(response.read())
- response.close()
- link = ''.join(link.splitlines()).replace('\'','"')
-
- videoUrl = re.compile('"file": "(.+?)"').findall(link)[0]
-
- if(isRequestForURL):
- if(isRequestForPlaylist):
- liz = xbmcgui.ListItem('[B]PLAY VIDEO[/B]', thumbnailImage='')
- playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
- playlist.add(url=videoUrl, listitem=liz)
- else:
- return videoUrl
- else:
- addLink ('[B]PLAY VIDEO[/B]',videoUrl,'')
-
- except: pass
-
- #Gamedorm.org
- try:
- match=re.compile('gamedorm.org/(.+?)&AJ;').findall(url)[0]
- req = urllib2.Request('http://www.gamedorm.org/'+match)
- req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
- response = urllib2.urlopen(req)
- link=urllib.unquote(response.read())
- response.close()
- link = ''.join(link.splitlines()).replace('\'','"')
-
- playlist = re.compile('playlist:\[(.+?)\]').findall(link)[0]
-
- playItems = re.compile('url: "(.+?)"').findall(playlist)
- videoUrl = ''
- for playItem in playItems:
- if not playItem.lower().endswith('jpg'):
- videoUrl = playItem
- break
-
- if(isRequestForURL):
- if(isRequestForPlaylist):
- liz = xbmcgui.ListItem('[B]PLAY VIDEO[/B]', thumbnailImage='')
- playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
- playlist.add(url=videoUrl, listitem=liz)
- else:
- return videoUrl
- else:
- addLink ('[B]PLAY VIDEO[/B]',videoUrl,'')
- except: pass
-
- #Play File
- try:
- videoUrl = re.compile('play\?file\=(.+?)&AJ;').findall(url)[0]
- if(isRequestForURL):
- if(isRequestForPlaylist):
- liz = xbmcgui.ListItem('[B]PLAY VIDEO[/B]', thumbnailImage='')
- playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
- playlist.add(url=videoUrl, listitem=liz)
- else:
- return videoUrl
- else:
- addLink ('[B]PLAY VIDEO[/B]',videoUrl,'')
- except: pass
-
-
- #MP4
- try:
- match=re.compile('http://(.+?).mp4&AJ;').findall(url)
- videoUrl = 'http://'+match[0]+'.mp4'
- imgUrl = ''
- if(isRequestForURL):
- if(isRequestForPlaylist):
- liz = xbmcgui.ListItem(name, thumbnailImage=imgUrl)
- playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
- playlist.add(url=videoUrl, listitem=liz)
- else:
- return videoUrl
- else:
- addLink ('[B]PLAY VIDEO[/B]: '+name,videoUrl,imgUrl)
-
- except: pass
-
- #YOUTUBE
- try:
-
- match=re.compile('http://www.youtube.com/watch\?v=(.+?)&AJ;').findall(url)
- if(len(match) == 0):
- match=re.compile('http://www.youtube.com/v/(.+?)&fs=1&AJ;').findall(url)
- code = match[0]
- linkImage = 'http://i.ytimg.com/vi/'+code+'/default.jpg'
- req = urllib2.Request('http://www.youtube.com/watch?v='+code+'&fmt=18')
- req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
- response = urllib2.urlopen(req)
- link=response.read()
- response.close()
-
- if len(re.compile('shortlink" href="http://youtu.be/(.+?)"').findall(link)) == 0:
- if len(re.compile('\'VIDEO_ID\': "(.+?)"').findall(link)) == 0:
- req = urllib2.Request('http://www.youtube.com/get_video_info?video_id='+code+'&asv=3&el=detailpage&hl=en_US')
- req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
- response = urllib2.urlopen(req)
- link=response.read()
- response.close()
- map = None
- match=re.compile('fmt_stream_map=(.+?)&').findall(link)
- if len(match) == 0:
- map=(re.compile('fmt_stream_map": "(.+?)"').findall(link)[0]).replace('\\/', '/')
- else:
- map=urllib.unquote(match[0]).decode('utf8').split('url=')
- if re.search('status=fail', link):
- return
- if map == None:
- return
- #print map
- highResoVid = ''
- youtubeVideoQual = dc.getSetting('videoQual')
- for attr in map:
- if attr == '':
- continue
- parts = attr.split('&qual')
- url = urllib.unquote(parts[0]).decode('utf8')
- print url
- qual = re.compile('&itag=(.+?)&').findall(url)[0]
- print qual
- if(qual == '13'):
- if(not(isRequestForURL)):
- addLink ('PLAY 3GP Low Quality - 176x144',url,linkImage)
- elif(highResoVid == ''):
- highResoVid = url
- if(qual == '17'):
- if(not(isRequestForURL)):
- addLink ('PLAY 3GP Medium Quality - 176x144',url,linkImage)
- elif(highResoVid == ''):
- highResoVid = url
- if(qual == '36'):
- if(not(isRequestForURL)):
- addLink ('PLAY 3GP High Quality - 320x240',url,linkImage)
- elif(highResoVid == ''):
- highResoVid = url
- if(qual == '5'):
- if(not(isRequestForURL)):
- addLink ('PLAY FLV Low Quality - 400\\327226',url,linkImage)
- elif(highResoVid == ''):
- highResoVid = url
- if(qual == '34'):
- if(not(isRequestForURL)):
- addLink ('PLAY FLV Medium Quality - 480x360',url,linkImage)
- elif(highResoVid == ''):
- highResoVid = url
- if(qual == '6'):
- if(not(isRequestForURL)):
- addLink ('PLAY FLV Medium Quality - 640\\327360',url,linkImage)
- elif(highResoVid == ''):
- highResoVid = url
- if(qual == '35'):
- if(not(isRequestForURL)):
- addLink ('PLAY FLV High Quality - 854\\327480',url,linkImage)
- else:
- highResoVid = url
- if(qual == '18'):
- if(not(isRequestForURL)):
- addLink ('PLAY MP4 High Quality - 480x360',url,linkImage)
- else:
- highResoVid = url
-
- if(qual == '22'):
- if(not(isRequestForURL)):
- addLink ('PLAY MP4 High Quality - 1280x720',url,linkImage)
- else:
- highResoVid = url
- if youtubeVideoQual == '1' or youtubeVideoQual == '2':
- break
- if(qual == '37'):
- if(not(isRequestForURL)):
- addLink ('PLAY MP4 High-2 Quality - 1920x1080',url,linkImage)
- else:
- highResoVid = url
- if youtubeVideoQual == '2':
- break
- if(qual == '38'):
- if(not(isRequestForURL)):
- addLink ('PLAY MP4 Epic Quality - 4096\\3272304',url,linkImage)
- else:
- highResoVid = url
- if youtubeVideoQual == '2':
- break
- if(qual == '43'):
- if(not(isRequestForURL)):
- addLink ('PLAY WEBM Medium Quality - 4096\\3272304',url,linkImage)
- else:
- highResoVid = url
- if(qual == '44'):
- if(not(isRequestForURL)):
- addLink ('PLAY WEBM High Quality - 4096\\3272304',url,linkImage)
- else:
- highResoVid = url
- if youtubeVideoQual == '1' or youtubeVideoQual == '2':
- break
- if(qual == '45'):
- if(not(isRequestForURL)):
- addLink ('PLAY WEBM High-2 Quality - 4096\\3272304',url,linkImage)
- else:
- highResoVid = url
- if youtubeVideoQual == '2':
- break
- print highResoVid
- if(isRequestForURL):
- if(isRequestForPlaylist):
- liz = xbmcgui.ListItem('VIDEO PART', thumbnailImage=linkImage)
- xbmc.PlayList(xbmc.PLAYLIST_VIDEO).add(url = highResoVid, listitem=liz)
- return highResoVid
- else:
- return highResoVid
- except: pass
-
- #GOOGLE VIDEO
- try:
- id=re.compile('docId=(.+?)&AJ;').findall(url)
- req = urllib2.Request('http://video.google.com/docinfo?%7B"docid":"' + id[0] + '"%7D')
- req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
- response = urllib2.urlopen(req)
- link=response.read()
- response.close()
- #print link
- link = ''.join(link.splitlines()).replace('\t','').replace('\'','"')
-
- videoTitle=re.compile('"Title":"(.+?)",').findall(link)[0]
-
- imgUrl=re.compile('"thumbnail_url":"(.+?)"').findall(link)[0].replace('\\u0026','&')
- videoUrl=re.compile('"streamer_url":"(.+?)"').findall(link)[0].replace('\\u0026','&')
-
- if(isRequestForURL):
- if(isRequestForPlaylist):
- liz = xbmcgui.ListItem(videoTitle, thumbnailImage=imgUrl)
- playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
- playlist.add(url=videoUrl, listitem=liz)
- else:
- return videoUrl
- else:
- addLink ('[B]PLAY VIDEO[/B]: '+videoTitle,videoUrl,imgUrl)
-
- except: pass
-
-
- #SATSUKAI
- try:
- match=re.compile('http://www.satsukai.com/(.+?)&AJ;').findall(url)[0]
- req = urllib2.Request(url)
- req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
- response = urllib2.urlopen(req)
- link=urllib.unquote(response.read())
- response.close()
- link = ''.join(link.splitlines()).replace('\t','').replace('\'','"')
- imgUrl=re.compile('so.addVariable\("image","(.+?)"\);').findall(link)[0]
- videoUrl=re.compile('so.addVariable\("file","(.+?)"\);').findall(link)[0]
- videoTitle = name
- if(isRequestForURL):
- if(isRequestForPlaylist):
- liz = xbmcgui.ListItem(videoTitle, thumbnailImage=imgUrl)
- playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
- playlist.add(url=videoUrl, listitem=liz)
- else:
- return videoUrl
- else:
- addLink ('[B]PLAY VIDEO[/B]: '+videoTitle,videoUrl,imgUrl)
-
- except: pass
-
- #4shared
- try:
- match=re.compile('.4shared.com/(.+?)&').findall(url)[0]
- videoUrl = 'http://' + re.compile('http://(.+?)&').findall(url)[0]
- imgUrl = ''
- videoTitle = name
- if(isRequestForURL):
- if(isRequestForPlaylist):
- liz = xbmcgui.ListItem(videoTitle, thumbnailImage=imgUrl)
- playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
- playlist.add(url=videoUrl, listitem=liz)
- else:
- return videoUrl
- else:
- addLink ('[B]PLAY VIDEO[/B]: '+videoTitle,videoUrl,imgUrl)
-
- except: pass
-
- #DAILYMOTION
- try:
- match=re.compile('http://www.dailymotion.com/swf/(.+?)&AJ;').findall(url)
- if(len(match) == 0):
- match=re.compile('http://www.dailymotion.com/video/(.+?)&AJ;').findall(url)
- link = 'http://www.dailymotion.com/video/'+str(match[0])
- req = urllib2.Request(link)
- req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
- response = urllib2.urlopen(req)
- link=response.read()
- response.close()
- sequence=re.compile('"sequence", "(.+?)"').findall(link)
- newseqeunce = urllib.unquote(sequence[0]).decode('utf8').replace('\\/','/')
- imgSrc=re.compile('og:image" content="(.+?)"').findall(link)
- if(len(imgSrc) == 0):
- imgSrc=re.compile('/jpeg" href="(.+?)"').findall(link)
- dm_low=re.compile('"sdURL":"(.+?)"').findall(newseqeunce)
- dm_high=re.compile('"hqURL":"(.+?)"').findall(newseqeunce)
- if(isRequestForURL):
- videoUrl = ''
- if(len(dm_high) == 0):
- videoUrl = dm_low[0]
- else:
- videoUrl = dm_high[0]
- if(isRequestForPlaylist):
- liz = xbmcgui.ListItem('EPISODE', thumbnailImage=imgSrc[0])
- playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
- playlist.add(url=videoUrl, listitem=liz)
- else:
- return videoUrl
- else:
- if(len(dm_low) > 0):
- addLink ('PLAY Standard Quality ',dm_low[0],imgSrc[0])
- if(len(dm_high) > 0):
- addLink ('PLAY High Quality ',dm_high[0],imgSrc[0])
- except: pass
-
-
- #YAHOO
- try:
- id=re.compile('http://d.yimg.com/static.video.yahoo.com/yep/YV_YEP.swf\?id=(.+?)&AJ;').findall(url)
- req = urllib2.Request('http://cosmos.bcst.yahoo.com/up/yep/process/getPlaylistFOP.php?node_id='+id[0])
- req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
- response = urllib2.urlopen(req)
- link=response.read()
- response.close()
- link = ''.join(link.splitlines()).replace('\t','').replace('\'','"')
-
- server=re.compile('<STREAM APP="(.+?)"').findall(link)
- urlPath=re.compile('FULLPATH="(.+?)"').findall(link)
- videoUrl=(server[0]+urlPath[0]).replace('&','&')
- imgInfo = re.compile('<THUMB TYPE="FULLSIZETHUMB"><\!\[CDATA\[(.+?)\]\]></THUMB>').findall(link)
- imgUrl = ''
- if(len(imgInfo) > 0):
- imgUrl = imgInfo[0]
- videoTitle = name
- if(isRequestForURL):
- if(isRequestForPlaylist):
- liz = xbmcgui.ListItem(videoTitle, thumbnailImage=imgUrl)
- playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
- playlist.add(url=videoUrl, listitem=liz)
- else:
- return videoUrl
- else:
- addLink ('[B]PLAY VIDEO[/B]: '+videoTitle,videoUrl,imgUrl)
- except: pass
- #MEGAVIDEO
- try:
- if not re.search('megavideo.com', url):
- raise
- id=re.compile('http://www.megavideo.com/v/(.+?)&').findall(url)
- if len(id) > 0:
- url = get_redirected_url('http://www.megavideo.com/v/'+id[0], None) + '&AJ;'
- id=re.compile('v=(.+?)&').findall(url)
- video_id = id[0].replace('p://www.megavideo.com/?d=','')
- print 'MEGAVIDEO ID = ' + video_id
- req = urllib2.Request('http://www.megavideo.com/xml/videolink.php?v=' + video_id)
- req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
- response = urllib2.urlopen(req)
- link=response.read()
- response.close()
- link = ''.join(link.splitlines()).replace('\t','').replace('\'','"')
- print link
- un=re.compile(' un="(.+?)"').findall(link)
- k1=re.compile(' k1="(.+?)"').findall(link)
- k2=re.compile(' k2="(.+?)"').findall(link)
- hashresult = decrypt(un[0], k1[0], k2[0])
-
- s=re.compile(' s="(.+?)"').findall(link)
-
- title=re.compile(' title="(.+?)"').findall(link)
- videoTitle = urllib.unquote_plus(title[0].replace('+',' '))
-
- imgUrl = ''
- videoUrl = "http://www" + s[0] + ".megavideo.com/files/" + hashresult + "/" + videoTitle + ".flv";
- print 'MEGA VIDEO url = '+videoUrl
- if(isRequestForURL):
- if(isRequestForPlaylist):
- liz = xbmcgui.ListItem(videoTitle, thumbnailImage=imgUrl)
- playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
- playlist.add(url=videoUrl, listitem=liz)
- else:
- return videoUrl
- else:
- addLink ('[B]PLAY VIDEO[/B]: '+videoTitle,videoUrl,imgUrl)
- except: pass
-
- #VEOH
- try:
- if not re.search('veoh.com', url):
- raise
- id=re.compile('permalinkId=v(.+?)&').findall(url)
- if len(id) == 0:
- id=re.compile('http://www.veoh.com/v(.+?)&').findall(url)
-
- url='http://www.veoh.com/rest/v2/execute.xml?method=veoh.video.findByPermalink&permalink=v'+id[0]+'&apiKey=E97FCECD-875D-D5EB-035C-8EF241F184E2'
- req = urllib2.Request(url)
- req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
- response = urllib2.urlopen(req)
- link=response.read()
- response.close()
- domObj = parseString(link)
- print domObj.toprettyxml()
- if len(domObj.getElementsByTagName("error")) > 0:
- print domObj.getElementsByTagName("error")[0].getAttribute('errorMessage')
- return
- videoUrl = get_redirected_url(domObj.getElementsByTagName("video")[0].getAttribute('ipodUrl'), None)
- imgUrl = domObj.getElementsByTagName("video")[0].getAttribute('fullHighResImagePath')
- videoTitle = name
- if(isRequestForURL):
- if(isRequestForPlaylist):
- liz = xbmcgui.ListItem(videoTitle, thumbnailImage=imgUrl)
- playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
- playlist.add(url=videoUrl, listitem=liz)
- else:
- return videoUrl
- else:
- addLink ('[B]PLAY VIDEO[/B]: '+videoTitle,videoUrl,imgUrl)
- except: pass
-
- #TUDOU
- try:
- id=re.compile('http://www.tudou.com/(.+?)&AJ;').findall(url)
- quotedUrl = urllib.quote('http://www.tudou.com/'+id[0])
- url = 'http://clipnabber.com/?url='+quotedUrl
- req = urllib2.Request(url)
- req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
- response = urllib2.urlopen(req)
- link=response.read()
- response.close()
- link = ''.join(link.splitlines()).replace('\t','').replace('\'','"')
-
- match=re.compile('<div id="Math">(.+?)</div>').findall(link)
-
- url = 'http://clipnabber.com/gethint.php?url='+quotedUrl+'&sid='+match[0]
-
- req = urllib2.Request(url)
- req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
- response = urllib2.urlopen(req)
- link=response.read()
- response.close()
- link = ''.join(link.splitlines()).replace('\t','').replace('\'','"')
- videoUrl=unescape(re.compile('<a href="(.+?)">').findall(link)[0])
- imgUrl = ''
- print 'TUDOU url = '+videoUrl
- videoTitle = name
- if(isRequestForURL):
- if(isRequestForPlaylist):
- liz = xbmcgui.ListItem(videoTitle, thumbnailImage=imgUrl)
- playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
- playlist.add(url=videoUrl, listitem=liz)
- else:
- return videoUrl
- else:
- addLink ('[B]PLAY VIDEO[/B]: '+videoTitle,videoUrl,imgUrl)
- except: pass
-
-
- #TFCNOW
- try:
- p=re.compile('http://playlist.tfcnow.net/(.+?)&AJ;')
- match=p.findall(url)
- link = match[0]
- req = urllib2.Request(url)
- req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
- response = urllib2.urlopen(req)
- link=response.read()
- response.close()
- link = ''.join(link.splitlines()).replace('\'','"')
- match=re.compile('src="(.+?)"').findall(link)
- loadVideos (match[0],name,False,False)
- except: pass
- #FACEBOOK
- try:
- match=re.compile('http://www.facebook.com/v/(.+?)&AJ;').findall(url)
- url='http://facebook.com/video/external_video.php?v='+match[0]
- req = urllib2.Request(url)
- req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
- response = urllib2.urlopen(req)
- link=urllib.unquote(response.read())
- response.close()
- link = ''.join(link.splitlines()).replace('\\/','/')
- videoTitle=re.compile('"video_title":"(.+?)"').findall(link)[0]
- imgUrl=re.compile('"thumb_url":"(.+?)"').findall(link)[0]
- videoUrl=re.compile('"video_src":"(.+?)"').findall(link)[0]
- if(isRequestForURL):
- if(isRequestForPlaylist):
- liz = xbmcgui.ListItem(videoTitle, thumbnailImage=imgUrl)
- playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
- playlist.add(url=videoUrl, listitem=liz)
- else:
- return videoUrl
- else:
- addLink ('[B]PLAY VIDEO[/B]: '+videoTitle,videoUrl,imgUrl)
-
- except: pass
-
- #MOVSHARE
- try:
- p=re.compile('http://www.movshare.net/video/(.+?)&AJ;')
- match=p.findall(url)
- movUrl = 'http://www.movshare.net/video…
Large files files are truncated, but you can click here to view the full file