PageRenderTime 45ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/addons/plugin.video.animecrazy/default.py

http://apple-tv2-xbmc.googlecode.com/
Python | 1249 lines | 1238 code | 8 blank | 3 comment | 7 complexity | 5cc93072a28e4be3859fc15e43269ac1 MD5 | raw file
Possible License(s): GPL-3.0
  1. import urllib,urllib2,re,sys,xbmcplugin,xbmcgui,httplib
  2. import cookielib,os,string,cookielib,StringIO
  3. import os,time,base64,logging
  4. import xbmcaddon
  5. from datetime import datetime
  6. try:
  7. import json
  8. except ImportError:
  9. import simplejson as json
  10. #animecrazy
  11. dc=xbmcaddon.Addon(id='plugin.video.animecrazy')
  12. addonPath=os.getcwd()
  13. artPath=addonPath+'/resources/art'
  14. def HOME():
  15. icon = os.path.join(xbmc.translatePath( addonPath ), 'icon.png')
  16. #addDir('Index','http://www.animecrazy.net/anime-index/',2,icon)
  17. addDir('Genres','http://www.animecrazy.net/anime-index/',3,icon)
  18. addDir('A-Z list','http://www.animecrazy.net/anime-index/',4,icon)
  19. addDir('Most Popular','http://www.animecrazy.net/most-popular/',5,icon)
  20. addDir('Most Recent','http://www.animecrazy.net/most-recent/',6,icon)
  21. searchIcon = os.path.join(xbmc.translatePath( artPath ), 'search-icon.png')
  22. addDir('Search','http://www.animecrazy.net/anime-index/',7,searchIcon)
  23. #addDir('NEW ADD-ON :: VEOH [I]beta[/I]', 'http://www.animecrazy.net/', 50, os.path.join(xbmc.translatePath( artPath ), "AJ.png"))
  24. def WHAT_IS_COMING(url):
  25. d = xbmcgui.Dialog()
  26. d.ok('NEW FEATURE: VEOH Video Support ADDED', 'DONATE today: \n[B]http://code.google.com/p/apple-tv2-xbmc/[/B]')
  27. def INDEX(url):
  28. url = 'http://www.animecrazy.net/anime-index/'
  29. req = urllib2.Request(url)
  30. 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')
  31. response = urllib2.urlopen(req)
  32. link=response.read()
  33. response.close()
  34. link = ''.join(link.splitlines()).replace('\t','')
  35. match=re.compile('<ul class="truindexlist">(.+?)</ul>').findall(link)
  36. if(len(match) >= 1):
  37. quickLinks=re.compile('<li><a href="#(.+?)">(.+?)</a></li>').findall(match[0])
  38. for quickLink, quickLinkName in quickLinks:
  39. 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)
  40. addDir(quickLinkName,match[0][1],21,'')
  41. def INDEX_A_Z(url):
  42. matches = re.compile('<ul class="truindexlist"><p class="truindexlistheader">(.+?)</p>(.+?)</ul>').findall(url)
  43. for char, videoList in matches:
  44. addDir(char,videoList,22,'')
  45. def INDEX_A_Z_VIDEOS(url):
  46. videoLinks = re.compile('<li><a href="/(.+?)">(.+?)</li>').findall(url)
  47. xbmc.executebuiltin("XBMC.Notification(Please Wait!,Retrieving video info and image,5000)")
  48. for videoLink, videoName in videoLinks:
  49. addVideoInfo_Image('http://www.animecrazy.net/' + videoLink, videoName)
  50. def GENRES(url):
  51. url = 'http://www.animecrazy.net/anime-index/'
  52. req = urllib2.Request(url)
  53. 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')
  54. response = urllib2.urlopen(req)
  55. link=response.read()
  56. response.close()
  57. link = ''.join(link.splitlines()).replace('\t','')
  58. match=re.compile('<strong>Genre:</strong>(.+?)</div>').findall(link)
  59. if(len(match) >= 1):
  60. genres=re.compile('<a href="/(.+?)">(.+?)</a>').findall(match[0])
  61. for genreLink, genreName in genres:
  62. addDir(genreName,'http://www.animecrazy.net/'+genreLink,31,'')
  63. def GENRE_VIDEOS(url):
  64. Video_List_Searched(url)
  65. def A_Z_LIST(url):
  66. addDir('A','http://www.animecrazy.net/alpha-a/',41,'')
  67. addDir('B','http://www.animecrazy.net/alpha-b/',41,'')
  68. addDir('C','http://www.animecrazy.net/alpha-c/',41,'')
  69. addDir('D','http://www.animecrazy.net/alpha-d/',41,'')
  70. addDir('E','http://www.animecrazy.net/alpha-e/',41,'')
  71. addDir('F','http://www.animecrazy.net/alpha-f/',41,'')
  72. addDir('G','http://www.animecrazy.net/alpha-g/',41,'')
  73. addDir('H','http://www.animecrazy.net/alpha-h/',41,'')
  74. addDir('I','http://www.animecrazy.net/alpha-i/',41,'')
  75. addDir('J','http://www.animecrazy.net/alpha-j/',41,'')
  76. addDir('K','http://www.animecrazy.net/alpha-k/',41,'')
  77. addDir('L','http://www.animecrazy.net/alpha-l/',41,'')
  78. addDir('M','http://www.animecrazy.net/alpha-m/',41,'')
  79. addDir('N','http://www.animecrazy.net/alpha-n/',41,'')
  80. addDir('O','http://www.animecrazy.net/alpha-o/',41,'')
  81. addDir('P','http://www.animecrazy.net/alpha-p/',41,'')
  82. addDir('Q','http://www.animecrazy.net/alpha-q/',41,'')
  83. addDir('R','http://www.animecrazy.net/alpha-r/',41,'')
  84. addDir('S','http://www.animecrazy.net/alpha-s/',41,'')
  85. addDir('Q','http://www.animecrazy.net/alpha-q/',41,'')
  86. addDir('U','http://www.animecrazy.net/alpha-u/',41,'')
  87. addDir('V','http://www.animecrazy.net/alpha-v/',41,'')
  88. addDir('W','http://www.animecrazy.net/alpha-w/',41,'')
  89. addDir('X','http://www.animecrazy.net/alpha-x/',41,'')
  90. addDir('Y','http://www.animecrazy.net/alpha-y/',41,'')
  91. addDir('Z','http://www.animecrazy.net/alpha-z/',41,'')
  92. def A_Z_LIST_VIDEOS(url):
  93. Video_List_And_Pagination(url)
  94. def MOST_POPULAR(url):
  95. Video_List_And_Pagination(url)
  96. def MOST_RECENT(url):
  97. Video_List_And_Pagination(url)
  98. def SEARCH(url):
  99. keyb = xbmc.Keyboard('', 'Enter search text')
  100. keyb.doModal()
  101. searchText = ''
  102. if (keyb.isConfirmed()):
  103. searchText = urllib.quote_plus(keyb.getText())
  104. url = 'http://www.animecrazy.net/search/'+searchText
  105. Video_List_Searched(url)
  106. def PAGES(url):
  107. Video_List_And_Pagination(url)
  108. def Video_List_Searched(url):
  109. req = urllib2.Request(url)
  110. 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')
  111. response = urllib2.urlopen(req)
  112. link=response.read()
  113. response.close()
  114. link = ''.join(link.splitlines()).replace('\t','')
  115. match=re.compile('<div class="top4">(.+?)<div class="clear"> </div></div>').findall(link)
  116. if(len(match) >= 1):
  117. videoInfo=re.compile('<a href="/(.+?)"><p>(.+?)</p><img src="(.+?)" alt="" width="150px" /></a>').findall(match[0])
  118. xbmc.executebuiltin("XBMC.Notification(Please Wait!,Retrieving video info and image,5000)")
  119. for videoLink, videoName, imgSrc in videoInfo:
  120. addVideoInfo_Image('http://www.animecrazy.net/' + videoLink, videoName)
  121. match=re.compile('<div class="moreActionResults contentModule">(.+?)</div><div class="clear"></div></div>').findall(link)
  122. if(len(match) >= 1):
  123. videoInfo=re.compile('<p class="longTitle floatLeft"><a href="/(.+?)">(.+?)</p>').findall(match[0])
  124. for videoLink, videoName in videoInfo:
  125. addVideoInfo_Image('http://www.animecrazy.net/' + videoLink, videoName)
  126. def Video_List_And_Pagination(url):
  127. req = urllib2.Request(url)
  128. 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')
  129. response = urllib2.urlopen(req)
  130. link=response.read()
  131. response.close()
  132. link = ''.join(link.splitlines()).replace('\t','')
  133. match=re.compile('<h1><a href="/(.+?)">(.+?)</a></h1>').findall(link)
  134. xbmc.executebuiltin("XBMC.Notification(Please Wait!,Retrieving video info and image,5000)")
  135. for videoLink, videoName in match:
  136. addVideoInfo_Image('http://www.animecrazy.net/' + videoLink, videoName)
  137. match=re.compile('<div class="paginationDiv">(.+?)<div class="clear"></div></div>').findall(link)
  138. if(len(match) >= 1):
  139. pages=re.compile('<a href="(.+?)">(.+?)</a>').findall(match[0])
  140. for pageUrl, page in pages:
  141. pageNbr = page.replace('&lsaquo;','<').replace('&rsaquo;','>').replace('&gt;','>').replace('&lt;','<')
  142. icon = ''
  143. dirName = ''
  144. if(pageNbr == '<'):
  145. dirName = '< PREVIOUS Page'
  146. icon = os.path.join(xbmc.translatePath( artPath ), 'prev-icon.png')
  147. elif(pageNbr == '>'):
  148. dirName = 'NEXT Page >'
  149. icon = os.path.join(xbmc.translatePath( artPath ), 'next-icon.png')
  150. elif(pageNbr == '< First'):
  151. dirName = '< FIRST Page'
  152. icon = os.path.join(xbmc.translatePath( artPath ), 'first-icon.png')
  153. elif(pageNbr == 'Last >'):
  154. dirName = 'LAST Page >'
  155. icon = os.path.join(xbmc.translatePath( artPath ), 'last-icon.png')
  156. else:
  157. dirName = 'TO Page: '+pageNbr
  158. addDir(dirName,pageUrl,8,icon)
  159. def addVideoInfo_Image(url, name):
  160. try:
  161. print url
  162. req = urllib2.Request(url)
  163. 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')
  164. response = urllib2.urlopen(req)
  165. link=response.read()
  166. response.close()
  167. link = ''.join(link.splitlines()).replace('\t','')
  168. imgUrl=re.compile('<img src="(.+?)" width="150px" alt="(.+?)Image" />').findall(link)[0][0]
  169. match=re.compile('<div class="text floatLeft">(.+?)</div>').findall(link)
  170. videoName=re.compile('<h1>(.+?)</h1>').findall(match[0])
  171. ranks=re.compile('<span class="position">(.+?)</span><br /><span class="totalNr">of (.+?)</span>').findall(match[0])
  172. videoTitle = videoName[0] + ' (Rank: ' + ranks[0][0] + ' of ' + ranks[0][1] +')'
  173. videoEpisodesUrl = url[0:len(url)-1] + '-episode-list/'
  174. addDir(videoTitle,videoEpisodesUrl,9,imgUrl)
  175. except httplib.IncompleteRead:
  176. xbmc.executebuiltin("XBMC.Notification(Skipped: "+name+",Continue retrieving video info and image about next video,5000)")
  177. pass
  178. def EPISODES_OR_MOVIE(url):
  179. url = url.replace('-anime-episode-list/', '-episode-list/')
  180. url = url.replace('-movie-episode-list/', '-movie/')
  181. req = urllib2.Request(url)
  182. 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')
  183. response = urllib2.urlopen(req)
  184. link=response.read()
  185. response.close()
  186. link = ''.join(link.splitlines()).replace('\t','')
  187. if re.search('404 Page Not Found', link):
  188. d = xbmcgui.Dialog()
  189. d.ok('NO episodes found','There are no episodes added for this drama.','Be the first to add episode, visit www.dramacrazy.net now','')
  190. return
  191. imgUrl = ''
  192. try:
  193. imgUrl='http://www.animecrazy.net/' + re.compile('<img src="/(.+?)" width="150px" alt="(.+?)Image" />').findall(link)[0][0]
  194. except:
  195. try:
  196. imgUrl='http://i.animecrazy.net/' + re.compile('<img src="http://i.animecrazy.net/(.+?)" width="150px" alt="(.+?)Image">').findall(link)[0][0]
  197. except:
  198. imgUrl = ''
  199. episodes=re.compile('<a class="floatLeft" id="episode(.+?)" href="/(.+?)">(.+?)</a> <p class="floatRight"> (.+?) </p>').findall(link)
  200. if(len(episodes) > 0):
  201. for episodeId, episodeUrl, episodeName, episodeAddedDate in episodes:
  202. episodeTitle = unescape(episodeName) +' (Added on: '+episodeAddedDate+')'
  203. addDir(episodeTitle,'http://www.animecrazy.net/' + episodeUrl,10,imgUrl)
  204. else:
  205. PARTS('http://www.animecrazy.net/' + re.compile('<a class="floatLeft" href="/(.+?)">(.+?)</a>').findall(link)[0][0])
  206. def PARTS(url):
  207. req = urllib2.Request(url)
  208. 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')
  209. response = urllib2.urlopen(req)
  210. link=response.read()
  211. response.close()
  212. link = ''.join(link.splitlines()).replace('\t','').replace('\'','"')
  213. streamingLinksModule=re.compile('<!-- Small Div alternate streaming mirros -->(.+?)<!--End of alternate streaming mirrors -->').findall(link)
  214. streamingLinks=re.compile('<div class="row">(.+?)<div class="clear"></div></div>').findall(streamingLinksModule[0])
  215. for stramingLinkRow in streamingLinks:
  216. parts = re.compile('<a (.+?) onclick="return encLink\("/(.+?)"\);" (.+?)>').findall(stramingLinkRow.replace(')"',');"'))
  217. streamingName = re.compile('Watch(.+?)\)').findall(stramingLinkRow)
  218. streamTypeName = 'Watch' + streamingName[0] + ')'
  219. if re.search('\(Wat\)', streamTypeName):
  220. continue
  221. matchCount = len(parts)
  222. if(matchCount > 1):
  223. i = 0
  224. playList = ''
  225. for temp1, partLink, temp2 in parts:
  226. i = i + 1
  227. print ' - PART: '+str(i)+' PART link = '+partLink
  228. partName = streamTypeName + ' - PART: '+str(i)
  229. addPlayableLink(partName,'http://www.animecrazy.net/' + partLink,16,'')
  230. playList = playList + 'http://www.animecrazy.net/' + partLink
  231. if(i < matchCount):
  232. playList = playList + ':;'
  233. addPlayListLink('------------->[B]Direct PLAY[/B]<------------- [I]Playlist of above ' + str(matchCount) + ' videos[/I]',playList,12,'')
  234. else:
  235. addPlayableLink('[B]SINGLE LINK[/B] ' + streamTypeName,'http://www.animecrazy.net/' + parts[0][1],16,'')
  236. def PLAYLIST_VIDEOLINKS(url,name):
  237. ok=True
  238. playList = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
  239. playList.clear()
  240. #time.sleep(2)
  241. links = url.split(':;')
  242. pDialog = xbmcgui.DialogProgress()
  243. ret = pDialog.create('Loading playlist...')
  244. totalLinks = len(links)
  245. loadedLinks = 0
  246. remaining_display = 'Videos loaded :: [B]'+str(loadedLinks)+' / '+str(totalLinks)+'[/B] into XBMC player playlist.'
  247. pDialog.update(0,'Please wait for the process to retrieve video link.',remaining_display)
  248. for videoLink in links:
  249. loadVideos(videoLink,name,True,True)
  250. loadedLinks = loadedLinks + 1
  251. percent = (loadedLinks * 100)/totalLinks
  252. #print percent
  253. remaining_display = 'Videos loaded :: [B]'+str(loadedLinks)+' / '+str(totalLinks)+'[/B] into XBMC player playlist.'
  254. pDialog.update(percent,'Please wait for the process to retrieve video link.',remaining_display)
  255. if (pDialog.iscanceled()):
  256. return False
  257. xbmcPlayer = xbmc.Player()
  258. xbmcPlayer.play(playList)
  259. if not xbmcPlayer.isPlayingVideo():
  260. d = xbmcgui.Dialog()
  261. d.ok('INVALID VIDEO PLAYLIST', 'The playlist videos were removed due to copyright issue.','Check other links.')
  262. return ok
  263. def LOAD_AND_PLAY_VIDEO(url,name):
  264. xbmc.executebuiltin("XBMC.Notification(PLease Wait!,Loading video link into XBMC Media Player,5000)")
  265. ok=True
  266. print url
  267. videoUrl = loadVideos(url,name,True,False)
  268. if videoUrl == None:
  269. d = xbmcgui.Dialog()
  270. d.ok('NO VIDEO FOUND', 'This video was removed due to copyright issue.','Check other links.')
  271. return False
  272. elif videoUrl == 'ERROR':
  273. return False
  274. xbmcPlayer = xbmc.Player()
  275. xbmcPlayer.play(videoUrl)
  276. return ok
  277. def VIDEOLINKS(url,name):
  278. loadVideos(url,name,False,False)
  279. def loadVideos(url,name,isRequestForURL,isRequestForPlaylist):
  280. req = urllib2.Request(url)
  281. 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')
  282. response = urllib2.urlopen(req)
  283. link=response.read()
  284. response.close()
  285. link = ''.join(link.splitlines()).replace('\t','').replace('\'','"')
  286. streamingPlayer = re.compile('document.write\(unescape\("(.+?)"\)\);').findall(link)
  287. if(len(streamingPlayer) == 0):
  288. episodeContent = re.compile('<div class="episodeContent">(.+?)</div>').findall(link)[0]
  289. url = re.compile('src="(.+?)"').findall(episodeContent)[0]
  290. req = urllib2.Request(url)
  291. 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')
  292. response = urllib2.urlopen(req)
  293. link=response.read()
  294. response.close()
  295. link = ''.join(link.splitlines()).replace('\t','').replace('\'','"')
  296. streamingPlayer = re.compile('document.write\(unescape\("(.+?)"\)\);').findall(link)
  297. if(len(streamingPlayer) == 0):
  298. streamingPlayer = [ urllib.quote_plus(link) ]
  299. frame = urllib.unquote_plus(streamingPlayer[0]).replace('\'','"').replace(' =','=').replace('= ','=')
  300. videoUrl = re.compile('config=(.+?)&amp;').findall(frame)
  301. if(len(videoUrl) == 0):
  302. videoUrl = re.compile('data="(.+?)"').findall(frame)
  303. if(len(videoUrl) == 0):
  304. videoUrl = re.compile('file=(.+?)&amp;autostart').findall(frame)
  305. if(len(videoUrl) == 0):
  306. videoUrl = re.compile('href="(.+?)"').findall(frame)
  307. if(len(videoUrl) == 0):
  308. videoUrl = re.compile('src="(.+?)"').findall(frame)
  309. url = videoUrl[0] + '&AJ;'
  310. print 'VIDEO LINK = '+url
  311. #ANIMECRAZY
  312. try:
  313. match=re.compile('http://www.animecrazy.net/(.+?)&AJ;').findall(url)[0]
  314. req = urllib2.Request('http://www.animecrazy.net/'+match)
  315. 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')
  316. response = urllib2.urlopen(req)
  317. link=urllib.unquote(response.read())
  318. response.close()
  319. link = ''.join(link.splitlines()).replace('\'','"')
  320. url = re.compile('<iframe src ="(.+?)"').findall(link)[0] + '&AJ;'
  321. print 'NEW url = '+url
  322. req = urllib2.Request(url)
  323. 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')
  324. response = urllib2.urlopen(req)
  325. link=urllib.unquote(response.read())
  326. response.close()
  327. link = ''.join(link.splitlines()).replace('\'','"')
  328. match = re.compile('"file": "(.+?)"').findall(link)
  329. if len(match) == 0:
  330. match = re.compile('<file>(.+?)</file>').findall(link)
  331. videoUrl = match[0]
  332. imgUrl = ''
  333. videoTitle = name
  334. if(isRequestForURL):
  335. if(isRequestForPlaylist):
  336. liz = xbmcgui.ListItem(videoTitle, thumbnailImage=imgUrl)
  337. playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
  338. playlist.add(url=videoUrl, listitem=liz)
  339. else:
  340. return videoUrl
  341. else:
  342. addLink ('[B]PLAY VIDEO[/B]: '+videoTitle,videoUrl,imgUrl)
  343. except: pass
  344. #DRAMACRAZY
  345. try:
  346. match=re.compile('http://www.dramacrazy.net/(.+?)&AJ;').findall(url)[0]
  347. req = urllib2.Request('http://www.dramacrazy.net/'+match)
  348. 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')
  349. response = urllib2.urlopen(req)
  350. link=urllib.unquote(response.read())
  351. response.close()
  352. link = ''.join(link.splitlines()).replace('\'','"')
  353. match = re.compile('<iframe src ="(.+?)"').findall(link)
  354. if len(match) > 0:
  355. frameUrl = match[0]
  356. req = urllib2.Request(frameUrl)
  357. 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')
  358. response = urllib2.urlopen(req)
  359. link=urllib.unquote(response.read())
  360. response.close()
  361. link = ''.join(link.splitlines()).replace('\'','"')
  362. match = re.compile('"file": "(.+?)"').findall(link)
  363. if len(match) == 0:
  364. match = re.compile('<file>(.+?)</file>').findall(link)
  365. videoUrl = match[0]
  366. imgUrl = ''
  367. videoTitle = name
  368. if(isRequestForURL):
  369. if(isRequestForPlaylist):
  370. liz = xbmcgui.ListItem(videoTitle, thumbnailImage=imgUrl)
  371. playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
  372. playlist.add(url=videoUrl, listitem=liz)
  373. else:
  374. return videoUrl
  375. else:
  376. addLink ('[B]PLAY VIDEO[/B]: '+videoTitle,videoUrl,imgUrl)
  377. except: pass
  378. #Gamedorm.net
  379. try:
  380. match=re.compile('gamedorm.net/(.+?)&AJ;').findall(url)[0]
  381. req = urllib2.Request('http://gamedorm.net/'+match)
  382. 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')
  383. response = urllib2.urlopen(req)
  384. link=urllib.unquote(response.read())
  385. response.close()
  386. link = ''.join(link.splitlines()).replace('\'','"')
  387. videoUrl = re.compile('"file": "(.+?)"').findall(link)[0]
  388. if(isRequestForURL):
  389. if(isRequestForPlaylist):
  390. liz = xbmcgui.ListItem('[B]PLAY VIDEO[/B]', thumbnailImage='')
  391. playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
  392. playlist.add(url=videoUrl, listitem=liz)
  393. else:
  394. return videoUrl
  395. else:
  396. addLink ('[B]PLAY VIDEO[/B]',videoUrl,'')
  397. except: pass
  398. #Gamedorm.org
  399. try:
  400. match=re.compile('gamedorm.org/(.+?)&AJ;').findall(url)[0]
  401. req = urllib2.Request('http://www.gamedorm.org/'+match)
  402. 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')
  403. response = urllib2.urlopen(req)
  404. link=urllib.unquote(response.read())
  405. response.close()
  406. link = ''.join(link.splitlines()).replace('\'','"')
  407. playlist = re.compile('playlist:\[(.+?)\]').findall(link)[0]
  408. playItems = re.compile('url: "(.+?)"').findall(playlist)
  409. videoUrl = ''
  410. for playItem in playItems:
  411. if not playItem.lower().endswith('jpg'):
  412. videoUrl = playItem
  413. break
  414. if(isRequestForURL):
  415. if(isRequestForPlaylist):
  416. liz = xbmcgui.ListItem('[B]PLAY VIDEO[/B]', thumbnailImage='')
  417. playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
  418. playlist.add(url=videoUrl, listitem=liz)
  419. else:
  420. return videoUrl
  421. else:
  422. addLink ('[B]PLAY VIDEO[/B]',videoUrl,'')
  423. except: pass
  424. #Play File
  425. try:
  426. videoUrl = re.compile('play\?file\=(.+?)&AJ;').findall(url)[0]
  427. if(isRequestForURL):
  428. if(isRequestForPlaylist):
  429. liz = xbmcgui.ListItem('[B]PLAY VIDEO[/B]', thumbnailImage='')
  430. playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
  431. playlist.add(url=videoUrl, listitem=liz)
  432. else:
  433. return videoUrl
  434. else:
  435. addLink ('[B]PLAY VIDEO[/B]',videoUrl,'')
  436. except: pass
  437. #MP4
  438. try:
  439. match=re.compile('http://(.+?).mp4&AJ;').findall(url)
  440. videoUrl = 'http://'+match[0]+'.mp4'
  441. imgUrl = ''
  442. if(isRequestForURL):
  443. if(isRequestForPlaylist):
  444. liz = xbmcgui.ListItem(name, thumbnailImage=imgUrl)
  445. playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
  446. playlist.add(url=videoUrl, listitem=liz)
  447. else:
  448. return videoUrl
  449. else:
  450. addLink ('[B]PLAY VIDEO[/B]: '+name,videoUrl,imgUrl)
  451. except: pass
  452. #YOUTUBE
  453. try:
  454. match=re.compile('http://www.youtube.com/watch\?v=(.+?)&AJ;').findall(url)
  455. if(len(match) == 0):
  456. match=re.compile('http://www.youtube.com/v/(.+?)&fs=1&AJ;').findall(url)
  457. code = match[0]
  458. linkImage = 'http://i.ytimg.com/vi/'+code+'/default.jpg'
  459. req = urllib2.Request('http://www.youtube.com/watch?v='+code+'&fmt=18')
  460. 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')
  461. response = urllib2.urlopen(req)
  462. link=response.read()
  463. response.close()
  464. if len(re.compile('shortlink" href="http://youtu.be/(.+?)"').findall(link)) == 0:
  465. if len(re.compile('\'VIDEO_ID\': "(.+?)"').findall(link)) == 0:
  466. req = urllib2.Request('http://www.youtube.com/get_video_info?video_id='+code+'&asv=3&el=detailpage&hl=en_US')
  467. 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')
  468. response = urllib2.urlopen(req)
  469. link=response.read()
  470. response.close()
  471. map = None
  472. match=re.compile('fmt_stream_map=(.+?)&').findall(link)
  473. if len(match) == 0:
  474. map=(re.compile('fmt_stream_map": "(.+?)"').findall(link)[0]).replace('\\/', '/')
  475. else:
  476. map=urllib.unquote(match[0]).decode('utf8').split('url=')
  477. if re.search('status=fail', link):
  478. return
  479. if map == None:
  480. return
  481. #print map
  482. highResoVid = ''
  483. youtubeVideoQual = dc.getSetting('videoQual')
  484. for attr in map:
  485. if attr == '':
  486. continue
  487. parts = attr.split('&qual')
  488. url = urllib.unquote(parts[0]).decode('utf8')
  489. print url
  490. qual = re.compile('&itag=(.+?)&').findall(url)[0]
  491. print qual
  492. if(qual == '13'):
  493. if(not(isRequestForURL)):
  494. addLink ('PLAY 3GP Low Quality - 176x144',url,linkImage)
  495. elif(highResoVid == ''):
  496. highResoVid = url
  497. if(qual == '17'):
  498. if(not(isRequestForURL)):
  499. addLink ('PLAY 3GP Medium Quality - 176x144',url,linkImage)
  500. elif(highResoVid == ''):
  501. highResoVid = url
  502. if(qual == '36'):
  503. if(not(isRequestForURL)):
  504. addLink ('PLAY 3GP High Quality - 320x240',url,linkImage)
  505. elif(highResoVid == ''):
  506. highResoVid = url
  507. if(qual == '5'):
  508. if(not(isRequestForURL)):
  509. addLink ('PLAY FLV Low Quality - 400\\327226',url,linkImage)
  510. elif(highResoVid == ''):
  511. highResoVid = url
  512. if(qual == '34'):
  513. if(not(isRequestForURL)):
  514. addLink ('PLAY FLV Medium Quality - 480x360',url,linkImage)
  515. elif(highResoVid == ''):
  516. highResoVid = url
  517. if(qual == '6'):
  518. if(not(isRequestForURL)):
  519. addLink ('PLAY FLV Medium Quality - 640\\327360',url,linkImage)
  520. elif(highResoVid == ''):
  521. highResoVid = url
  522. if(qual == '35'):
  523. if(not(isRequestForURL)):
  524. addLink ('PLAY FLV High Quality - 854\\327480',url,linkImage)
  525. else:
  526. highResoVid = url
  527. if(qual == '18'):
  528. if(not(isRequestForURL)):
  529. addLink ('PLAY MP4 High Quality - 480x360',url,linkImage)
  530. else:
  531. highResoVid = url
  532. if(qual == '22'):
  533. if(not(isRequestForURL)):
  534. addLink ('PLAY MP4 High Quality - 1280x720',url,linkImage)
  535. else:
  536. highResoVid = url
  537. if youtubeVideoQual == '1' or youtubeVideoQual == '2':
  538. break
  539. if(qual == '37'):
  540. if(not(isRequestForURL)):
  541. addLink ('PLAY MP4 High-2 Quality - 1920x1080',url,linkImage)
  542. else:
  543. highResoVid = url
  544. if youtubeVideoQual == '2':
  545. break
  546. if(qual == '38'):
  547. if(not(isRequestForURL)):
  548. addLink ('PLAY MP4 Epic Quality - 4096\\3272304',url,linkImage)
  549. else:
  550. highResoVid = url
  551. if youtubeVideoQual == '2':
  552. break
  553. if(qual == '43'):
  554. if(not(isRequestForURL)):
  555. addLink ('PLAY WEBM Medium Quality - 4096\\3272304',url,linkImage)
  556. else:
  557. highResoVid = url
  558. if(qual == '44'):
  559. if(not(isRequestForURL)):
  560. addLink ('PLAY WEBM High Quality - 4096\\3272304',url,linkImage)
  561. else:
  562. highResoVid = url
  563. if youtubeVideoQual == '1' or youtubeVideoQual == '2':
  564. break
  565. if(qual == '45'):
  566. if(not(isRequestForURL)):
  567. addLink ('PLAY WEBM High-2 Quality - 4096\\3272304',url,linkImage)
  568. else:
  569. highResoVid = url
  570. if youtubeVideoQual == '2':
  571. break
  572. print highResoVid
  573. if(isRequestForURL):
  574. if(isRequestForPlaylist):
  575. liz = xbmcgui.ListItem('VIDEO PART', thumbnailImage=linkImage)
  576. xbmc.PlayList(xbmc.PLAYLIST_VIDEO).add(url = highResoVid, listitem=liz)
  577. return highResoVid
  578. else:
  579. return highResoVid
  580. except: pass
  581. #GOOGLE VIDEO
  582. try:
  583. id=re.compile('docId=(.+?)&AJ;').findall(url)
  584. req = urllib2.Request('http://video.google.com/docinfo?%7B"docid":"' + id[0] + '"%7D')
  585. 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')
  586. response = urllib2.urlopen(req)
  587. link=response.read()
  588. response.close()
  589. #print link
  590. link = ''.join(link.splitlines()).replace('\t','').replace('\'','"')
  591. videoTitle=re.compile('"Title":"(.+?)",').findall(link)[0]
  592. imgUrl=re.compile('"thumbnail_url":"(.+?)"').findall(link)[0].replace('\\u0026','&')
  593. videoUrl=re.compile('"streamer_url":"(.+?)"').findall(link)[0].replace('\\u0026','&')
  594. if(isRequestForURL):
  595. if(isRequestForPlaylist):
  596. liz = xbmcgui.ListItem(videoTitle, thumbnailImage=imgUrl)
  597. playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
  598. playlist.add(url=videoUrl, listitem=liz)
  599. else:
  600. return videoUrl
  601. else:
  602. addLink ('[B]PLAY VIDEO[/B]: '+videoTitle,videoUrl,imgUrl)
  603. except: pass
  604. #SATSUKAI
  605. try:
  606. match=re.compile('http://www.satsukai.com/(.+?)&AJ;').findall(url)[0]
  607. req = urllib2.Request(url)
  608. 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')
  609. response = urllib2.urlopen(req)
  610. link=urllib.unquote(response.read())
  611. response.close()
  612. link = ''.join(link.splitlines()).replace('\t','').replace('\'','"')
  613. imgUrl=re.compile('so.addVariable\("image","(.+?)"\);').findall(link)[0]
  614. videoUrl=re.compile('so.addVariable\("file","(.+?)"\);').findall(link)[0]
  615. videoTitle = name
  616. if(isRequestForURL):
  617. if(isRequestForPlaylist):
  618. liz = xbmcgui.ListItem(videoTitle, thumbnailImage=imgUrl)
  619. playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
  620. playlist.add(url=videoUrl, listitem=liz)
  621. else:
  622. return videoUrl
  623. else:
  624. addLink ('[B]PLAY VIDEO[/B]: '+videoTitle,videoUrl,imgUrl)
  625. except: pass
  626. #4shared
  627. try:
  628. match=re.compile('.4shared.com/(.+?)&amp;').findall(url)[0]
  629. videoUrl = 'http://' + re.compile('http://(.+?)&amp;').findall(url)[0]
  630. imgUrl = ''
  631. videoTitle = name
  632. if(isRequestForURL):
  633. if(isRequestForPlaylist):
  634. liz = xbmcgui.ListItem(videoTitle, thumbnailImage=imgUrl)
  635. playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
  636. playlist.add(url=videoUrl, listitem=liz)
  637. else:
  638. return videoUrl
  639. else:
  640. addLink ('[B]PLAY VIDEO[/B]: '+videoTitle,videoUrl,imgUrl)
  641. except: pass
  642. #DAILYMOTION
  643. try:
  644. match=re.compile('http://www.dailymotion.com/swf/(.+?)&AJ;').findall(url)
  645. if(len(match) == 0):
  646. match=re.compile('http://www.dailymotion.com/video/(.+?)&AJ;').findall(url)
  647. link = 'http://www.dailymotion.com/video/'+str(match[0])
  648. req = urllib2.Request(link)
  649. 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')
  650. response = urllib2.urlopen(req)
  651. link=response.read()
  652. response.close()
  653. sequence=re.compile('"sequence", "(.+?)"').findall(link)
  654. newseqeunce = urllib.unquote(sequence[0]).decode('utf8').replace('\\/','/')
  655. imgSrc=re.compile('og:image" content="(.+?)"').findall(link)
  656. if(len(imgSrc) == 0):
  657. imgSrc=re.compile('/jpeg" href="(.+?)"').findall(link)
  658. dm_low=re.compile('"sdURL":"(.+?)"').findall(newseqeunce)
  659. dm_high=re.compile('"hqURL":"(.+?)"').findall(newseqeunce)
  660. if(isRequestForURL):
  661. videoUrl = ''
  662. if(len(dm_high) == 0):
  663. videoUrl = dm_low[0]
  664. else:
  665. videoUrl = dm_high[0]
  666. if(isRequestForPlaylist):
  667. liz = xbmcgui.ListItem('EPISODE', thumbnailImage=imgSrc[0])
  668. playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
  669. playlist.add(url=videoUrl, listitem=liz)
  670. else:
  671. return videoUrl
  672. else:
  673. if(len(dm_low) > 0):
  674. addLink ('PLAY Standard Quality ',dm_low[0],imgSrc[0])
  675. if(len(dm_high) > 0):
  676. addLink ('PLAY High Quality ',dm_high[0],imgSrc[0])
  677. except: pass
  678. #YAHOO
  679. try:
  680. id=re.compile('http://d.yimg.com/static.video.yahoo.com/yep/YV_YEP.swf\?id=(.+?)&AJ;').findall(url)
  681. req = urllib2.Request('http://cosmos.bcst.yahoo.com/up/yep/process/getPlaylistFOP.php?node_id='+id[0])
  682. 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')
  683. response = urllib2.urlopen(req)
  684. link=response.read()
  685. response.close()
  686. link = ''.join(link.splitlines()).replace('\t','').replace('\'','"')
  687. server=re.compile('<STREAM APP="(.+?)"').findall(link)
  688. urlPath=re.compile('FULLPATH="(.+?)"').findall(link)
  689. videoUrl=(server[0]+urlPath[0]).replace('&amp;','&')
  690. imgInfo = re.compile('<THUMB TYPE="FULLSIZETHUMB"><\!\[CDATA\[(.+?)\]\]></THUMB>').findall(link)
  691. imgUrl = ''
  692. if(len(imgInfo) > 0):
  693. imgUrl = imgInfo[0]
  694. videoTitle = name
  695. if(isRequestForURL):
  696. if(isRequestForPlaylist):
  697. liz = xbmcgui.ListItem(videoTitle, thumbnailImage=imgUrl)
  698. playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
  699. playlist.add(url=videoUrl, listitem=liz)
  700. else:
  701. return videoUrl
  702. else:
  703. addLink ('[B]PLAY VIDEO[/B]: '+videoTitle,videoUrl,imgUrl)
  704. except: pass
  705. #MEGAVIDEO
  706. try:
  707. if not re.search('megavideo.com', url):
  708. raise
  709. id=re.compile('http://www.megavideo.com/v/(.+?)&').findall(url)
  710. if len(id) > 0:
  711. url = get_redirected_url('http://www.megavideo.com/v/'+id[0], None) + '&AJ;'
  712. id=re.compile('v=(.+?)&').findall(url)
  713. video_id = id[0].replace('p://www.megavideo.com/?d=','')
  714. print 'MEGAVIDEO ID = ' + video_id
  715. req = urllib2.Request('http://www.megavideo.com/xml/videolink.php?v=' + video_id)
  716. 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')
  717. response = urllib2.urlopen(req)
  718. link=response.read()
  719. response.close()
  720. link = ''.join(link.splitlines()).replace('\t','').replace('\'','"')
  721. print link
  722. un=re.compile(' un="(.+?)"').findall(link)
  723. k1=re.compile(' k1="(.+?)"').findall(link)
  724. k2=re.compile(' k2="(.+?)"').findall(link)
  725. hashresult = decrypt(un[0], k1[0], k2[0])
  726. s=re.compile(' s="(.+?)"').findall(link)
  727. title=re.compile(' title="(.+?)"').findall(link)
  728. videoTitle = urllib.unquote_plus(title[0].replace('+',' '))
  729. imgUrl = ''
  730. videoUrl = "http://www" + s[0] + ".megavideo.com/files/" + hashresult + "/" + videoTitle + ".flv";
  731. print 'MEGA VIDEO url = '+videoUrl
  732. if(isRequestForURL):
  733. if(isRequestForPlaylist):
  734. liz = xbmcgui.ListItem(videoTitle, thumbnailImage=imgUrl)
  735. playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
  736. playlist.add(url=videoUrl, listitem=liz)
  737. else:
  738. return videoUrl
  739. else:
  740. addLink ('[B]PLAY VIDEO[/B]: '+videoTitle,videoUrl,imgUrl)
  741. except: pass
  742. #VEOH
  743. try:
  744. if not re.search('veoh.com', url):
  745. raise
  746. id=re.compile('permalinkId=v(.+?)&').findall(url)
  747. if len(id) == 0:
  748. id=re.compile('http://www.veoh.com/v(.+?)&').findall(url)
  749. url='http://www.veoh.com/rest/v2/execute.xml?method=veoh.video.findByPermalink&permalink=v'+id[0]+'&apiKey=E97FCECD-875D-D5EB-035C-8EF241F184E2'
  750. req = urllib2.Request(url)
  751. 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')
  752. response = urllib2.urlopen(req)
  753. link=response.read()
  754. response.close()
  755. domObj = parseString(link)
  756. print domObj.toprettyxml()
  757. if len(domObj.getElementsByTagName("error")) > 0:
  758. print domObj.getElementsByTagName("error")[0].getAttribute('errorMessage')
  759. return
  760. videoUrl = get_redirected_url(domObj.getElementsByTagName("video")[0].getAttribute('ipodUrl'), None)
  761. imgUrl = domObj.getElementsByTagName("video")[0].getAttribute('fullHighResImagePath')
  762. videoTitle = name
  763. if(isRequestForURL):
  764. if(isRequestForPlaylist):
  765. liz = xbmcgui.ListItem(videoTitle, thumbnailImage=imgUrl)
  766. playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
  767. playlist.add(url=videoUrl, listitem=liz)
  768. else:
  769. return videoUrl
  770. else:
  771. addLink ('[B]PLAY VIDEO[/B]: '+videoTitle,videoUrl,imgUrl)
  772. except: pass
  773. #TUDOU
  774. try:
  775. id=re.compile('http://www.tudou.com/(.+?)&AJ;').findall(url)
  776. quotedUrl = urllib.quote('http://www.tudou.com/'+id[0])
  777. url = 'http://clipnabber.com/?url='+quotedUrl
  778. req = urllib2.Request(url)
  779. 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')
  780. response = urllib2.urlopen(req)
  781. link=response.read()
  782. response.close()
  783. link = ''.join(link.splitlines()).replace('\t','').replace('\'','"')
  784. match=re.compile('<div id="Math">(.+?)</div>').findall(link)
  785. url = 'http://clipnabber.com/gethint.php?url='+quotedUrl+'&sid='+match[0]
  786. req = urllib2.Request(url)
  787. 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')
  788. response = urllib2.urlopen(req)
  789. link=response.read()
  790. response.close()
  791. link = ''.join(link.splitlines()).replace('\t','').replace('\'','"')
  792. videoUrl=unescape(re.compile('<a href="(.+?)">').findall(link)[0])
  793. imgUrl = ''
  794. print 'TUDOU url = '+videoUrl
  795. videoTitle = name
  796. if(isRequestForURL):
  797. if(isRequestForPlaylist):
  798. liz = xbmcgui.ListItem(videoTitle, thumbnailImage=imgUrl)
  799. playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
  800. playlist.add(url=videoUrl, listitem=liz)
  801. else:
  802. return videoUrl
  803. else:
  804. addLink ('[B]PLAY VIDEO[/B]: '+videoTitle,videoUrl,imgUrl)
  805. except: pass
  806. #TFCNOW
  807. try:
  808. p=re.compile('http://playlist.tfcnow.net/(.+?)&AJ;')
  809. match=p.findall(url)
  810. link = match[0]
  811. req = urllib2.Request(url)
  812. 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')
  813. response = urllib2.urlopen(req)
  814. link=response.read()
  815. response.close()
  816. link = ''.join(link.splitlines()).replace('\'','"')
  817. match=re.compile('src="(.+?)"').findall(link)
  818. loadVideos (match[0],name,False,False)
  819. except: pass
  820. #FACEBOOK
  821. try:
  822. match=re.compile('http://www.facebook.com/v/(.+?)&AJ;').findall(url)
  823. url='http://facebook.com/video/external_video.php?v='+match[0]
  824. req = urllib2.Request(url)
  825. 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')
  826. response = urllib2.urlopen(req)
  827. link=urllib.unquote(response.read())
  828. response.close()
  829. link = ''.join(link.splitlines()).replace('\\/','/')
  830. videoTitle=re.compile('"video_title":"(.+?)"').findall(link)[0]
  831. imgUrl=re.compile('"thumb_url":"(.+?)"').findall(link)[0]
  832. videoUrl=re.compile('"video_src":"(.+?)"').findall(link)[0]
  833. if(isRequestForURL):
  834. if(isRequestForPlaylist):
  835. liz = xbmcgui.ListItem(videoTitle, thumbnailImage=imgUrl)
  836. playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
  837. playlist.add(url=videoUrl, listitem=liz)
  838. else:
  839. return videoUrl
  840. else:
  841. addLink ('[B]PLAY VIDEO[/B]: '+videoTitle,videoUrl,imgUrl)
  842. except: pass
  843. #MOVSHARE
  844. try:
  845. p=re.compile('http://www.movshare.net/video/(.+?)&AJ;')
  846. match=p.findall(url)
  847. movUrl = 'http://www.movshare.net/video/'+match[0]
  848. req = urllib2.Request(movUrl)
  849. 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')
  850. response = urllib2.urlopen(req)
  851. link=response.read()
  852. response.close()
  853. link = ''.join(link.splitlines()).replace('\t','').replace('\'','"')
  854. if re.search('Video hosting is expensive. We need you to prove you"re human.',link):
  855. values = {'wm': '1'}
  856. headers = { 'User-Agent' : 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3' }
  857. data = urllib.urlencode(values)
  858. req = urllib2.Request(movUrl, data, headers)
  859. response = urllib2.urlopen(req)
  860. link=response.read()
  861. response.close()
  862. link = ''.join(link.splitlines()).replace('\t','').replace('\'','"')
  863. match=re.compile('<param name="src" value="(.+?)" />').findall(link)
  864. if(len(match) == 0):
  865. match=re.compile('flashvars.file="(.+?)"')
  866. imgUrl = ''
  867. videoUrl=match[0]
  868. videoTitle = name
  869. if(isRequestForURL):
  870. if(isRequestForPlaylist):
  871. liz = xbmcgui.ListItem(videoTitle, thumbnailImage=imgUrl)
  872. playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
  873. playlist.add(url=videoUrl, listitem=liz)
  874. else:
  875. return videoUrl
  876. else:
  877. addLink ('[B]PLAY VIDEO[/B]: '+videoTitle,videoUrl,imgUrl)
  878. except: pass
  879. #VIDEOWEED
  880. try:
  881. p=re.compile('http://(.+?).videoweed(.+?)&AJ;')
  882. match=p.findall(url)
  883. link = match[0]
  884. req = urllib2.Request(url.replace('&AJ;',''))
  885. 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')
  886. response = urllib2.urlopen(req)
  887. link=response.read()
  888. response.close()
  889. imgUrl = ''
  890. file=re.compile('.file="(.+?)"').findall(link)[0]
  891. filekey=re.compile('.filekey="(.+?)"').findall(link)[0]
  892. newUrl = "http://www.videoweed.es/api/player.api.php?user=undefined&codes=undefined&pass=undefined&file=" + file + "&key=" + filekey
  893. req = urllib2.Request(newUrl)
  894. 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')
  895. response = urllib2.urlopen(req)
  896. link=response.read()
  897. response.close()
  898. videoUrl = re.compile('url=(.+?)&').findall(link)[0]
  899. videoTitle = name
  900. if(isRequestForURL):
  901. if(isRequestForPlaylist):
  902. liz = xbmcgui.ListItem(videoTitle, thumbnailImage=imgUrl)
  903. playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
  904. playlist.add(url=videoUrl, listitem=liz)
  905. else:
  906. return videoUrl
  907. else:
  908. addLink ('[B]PLAY VIDEO[/B]: '+videoTitle,videoUrl,imgUrl)
  909. except: pass
  910. #LOOMBO
  911. try:
  912. p=re.compile('http://loombo.com/(.+?)&AJ;')
  913. match=p.findall(url)
  914. link = match[0]
  915. req = urllib2.Request(url)
  916. 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')
  917. response = urllib2.urlopen(req)
  918. link=response.read()
  919. response.close()
  920. link = ''.join(link.splitlines()).replace('\'','"')
  921. match=re.compile('s1.addVariable\("file","(.+?)"\);').findall(link)
  922. imgUrl = ''
  923. videoUrl=match[0]
  924. videoTitle = name
  925. if(isRequestForURL):
  926. if(isRequestForPlaylist):
  927. liz = xbmcgui.ListItem(videoTitle, thumbnailImage=imgUrl)
  928. playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
  929. playlist.add(url=videoUrl, listitem=liz)
  930. else:
  931. return videoUrl
  932. else:
  933. addLink ('[B]PLAY VIDEO[/B]: '+videoTitle,videoUrl,imgUrl)
  934. except: pass
  935. #VIDEO BAM MP4
  936. try:
  937. p=re.compile('http://videobam.com/(.+?)&AJ;')
  938. match=p.findall(url)
  939. link = match[0]
  940. req = urllib2.Request(url)
  941. 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')
  942. response = urllib2.urlopen(req)
  943. link=response.read()
  944. response.close()
  945. link = ''.join(link.splitlines()).replace('\'','"')
  946. match=re.compile('<source src="(.+?)"').findall(link)
  947. imgUrl = ''
  948. videoUrl=match[0]
  949. videoTitle = name
  950. if(isRequestForURL):
  951. if(isRequestForPlaylist):
  952. liz = xbmcgui.ListItem(videoTitle, thumbnailImage=imgUrl)
  953. playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
  954. playlist.add(url=videoUrl, listitem=liz)
  955. else:
  956. return videoUrl
  957. else:
  958. addLink ('[B]PLAY VIDEO[/B]: '+videoTitle,videoUrl,imgUrl)
  959. except: pass
  960. #VIDBUX
  961. try:
  962. p=re.compile('http://www.vidbux.com/(.+?)&AJ;')
  963. match=p.findall(url)
  964. link = match[0]
  965. xbmc.executebuiltin("XBMC.Notification(SKIPPING...,Low Quality links are skipped,5000)")
  966. if(isRequestForURL and not isRequestForPlaylist):
  967. return 'ERROR'
  968. except: pass
  969. #VIDEOBB
  970. try:
  971. p=re.compile('videobb.com/e/(.+?)&AJ;')
  972. match=p.findall(url)
  973. url='http://www.videobb.com/player_control/settings.php?v='+match[0]
  974. settingsObj = json.load(urllib.urlopen(url))['settings']
  975. imgUrl = str(settingsObj['config']['thumbnail'])
  976. videoUrl = str(base64.b64decode(settingsObj['config']['token1']))
  977. videoTitle = name
  978. if(isRequestForURL):
  979. if(isRequestForPlaylist):
  980. liz = xbmcgui.ListItem(videoTitle, thumbnailImage=imgUrl)
  981. playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
  982. playlist.add(url=videoUrl, listitem=liz)
  983. else:
  984. return videoUrl
  985. else:
  986. addLink ('[B]PLAY VIDEO[/B]: '+videoTitle,videoUrl,imgUrl)
  987. except: pass
  988. #Z-SHARE
  989. try:
  990. id=re.compile('http://www.zshare.net/(.+?)&AJ;').findall(url)[0]
  991. H=re.compile('&H=(.+?)&').findall(url)[0]
  992. downloadUrl = 'http://www.zshare.net/download/' + H + '/'
  993. print downloadUrl
  994. req = urllib2.Request(downloadUrl)
  995. 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')
  996. response = urllib2.urlopen(req)
  997. link=response.read()
  998. response.close()
  999. link = ''.join(link.splitlines()).replace('\t','').replace('\'','"')
  1000. referrer = re.compile('<input name="referer2" type="hidden" id="referer2" value="(.+?)">').findall(link)[0]
  1001. id = re.compile('<input name="download" type="hidden" id="download" value="(.+?)">').findall(link)[0]
  1002. values = {'referer2': referrer,'download': id}
  1003. headers = { 'User-Agent' : 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3' }
  1004. data = urllib.urlencode(values)
  1005. req = urllib2.Request(downloadUrl, data, headers)
  1006. response = urllib2.urlopen(req)
  1007. link=response.read()
  1008. response.close()
  1009. link = ''.join(link.splitlines()).replace('\t','').replace('\'','"')
  1010. link_enc = re.compile('var link_enc=new Array\((.+?)\);').findall(link)[0]
  1011. link_chars = re.compile('"(.+?)"').findall(link_enc)
  1012. link = ''
  1013. for chars in link_chars:
  1014. link = link + chars
  1015. #print link
  1016. display_wait(50,'Z-Share - Retieving Video Link','I know you can\'t wait but thats the way it works.')
  1017. if(isRequestForURL):
  1018. if(isRequestForPlaylist):
  1019. liz = xbmcgui.ListItem('EPISODE', thumbnailImage='')
  1020. xbmc.PlayList(xbmc.PLAYLIST_VIDEO).add(url = link, listitem=liz)
  1021. else:
  1022. return videoUrl
  1023. else:
  1024. addLink ('PLAY High Quality Video',link,'')
  1025. except: pass
  1026. ####################################################################################################################
  1027. # MegaVideo Routine
  1028. ####################################################################################################################
  1029. #Python Video Decryption and resolving routines.
  1030. #Courtesy of Voinage, Coolblaze.
  1031. #Megavideo - Coolblaze # Part 1 put this below VIDEOLINKS function.
  1032. def ajoin(arr):
  1033. strtest = ''
  1034. for num in range(len(arr)):
  1035. strtest = strtest + str(arr[num])
  1036. return strtest
  1037. def asplit(mystring):
  1038. arr = []
  1039. for num in range(len(mystring)):
  1040. arr.append(mystring[num])
  1041. return arr
  1042. def decrypt(str1, key1, key2):
  1043. __reg1 = []
  1044. __reg3 = 0
  1045. while (__reg3 < len(str1)):
  1046. __reg0 = str1[__reg3]
  1047. holder = __reg0
  1048. if (holder == "0"):
  1049. __reg1.append("0000")
  1050. else:
  1051. if (__reg0 == "1"):
  1052. __reg1.append("0001")
  1053. else:
  1054. if (__reg0 == "2"):
  1055. __reg1.append("0010")
  1056. else:
  1057. if (__reg0 == "3"):
  1058. __reg1.append("0011")
  1059. else:
  1060. if (__reg0 == "4"):
  1061. __reg1.append("0100")
  1062. else:
  1063. if (__reg0 == "5"):
  1064. __reg1.append("0101")
  1065. else:
  1066. if (__reg0 == "6"):
  1067. __reg1.append("0110")
  1068. else:
  1069. if (__reg0 == "7"):
  1070. __reg1.append("0111")
  1071. else:
  1072. if (__reg0 == "8"):
  1073. __reg1.append("1000")
  1074. else:
  1075. if (__reg0 == "9"):
  1076. __reg1.append("1001")
  1077. else:
  1078. if (__reg0 == "a"):
  1079. __reg1.append("1010")
  1080. else:
  1081. if (__reg0 == "b"):
  1082. __reg1.append("1011")
  1083. else:
  1084. if (__reg0 == "c"):
  1085. __reg1.append("1100")
  1086. else:
  1087. if (__reg0 == "d"):
  1088. __reg1.append("1101")
  1089. else:
  1090. if (__reg0 == "e"):
  1091. __reg1.append("1110")
  1092. else:
  1093. if (__reg0 == "f"):
  1094. __reg1.append("1111")
  1095. __reg3 = __reg3 + 1
  1096. mtstr = ajoin(__reg1)
  1097. __reg1 = asplit(mtstr)
  1098. __reg6 = []
  1099. __reg3 = 0
  1100. while (__reg3 < 384):
  1101. key1 = (int(key1) * 11 + 77213) % 81371
  1102. key2 = (int(key2) * 17 + 92717) % 192811