PageRenderTime 58ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/addons/plugin.video.filmibynature/default.py

http://apple-tv2-xbmc.googlecode.com/
Python | 1123 lines | 1091 code | 25 blank | 7 comment | 10 complexity | 077e894ade5a42db95ec5d3d3d6e6278 MD5 | raw file
Possible License(s): GPL-3.0
  1. import urllib, urllib2, re, sys, xbmcplugin, xbmcgui
  2. import cookielib, os, string, cookielib, StringIO
  3. import os, time, base64, logging, calendar, binascii
  4. import xbmcaddon
  5. from xml.dom.minidom import parse, parseString
  6. from datetime import datetime
  7. try:
  8. import json
  9. except ImportError:
  10. import simplejson as json
  11. #Filmi by nature
  12. fbn = xbmcaddon.Addon(id=re.compile("plugin://(.+?)/").findall(sys.argv[0])[0])
  13. addonPath = fbn.getAddonInfo('path')
  14. artPath = addonPath + '/resources/art'
  15. resourcePath = addonPath + '/resources'
  16. defaultIconImg = os.path.join(xbmc.translatePath(addonPath), "icon.png")
  17. addonDataPath = fbn.getAddonInfo('profile')
  18. movieImgUrlJsonFile = 'MovieImgUrl_V2.json'
  19. octoshapeChannelsFile = 'Octoshape-Channels.json'
  20. yeahChannelsFile = 'Yeah-Channels.json'
  21. cachedImgUrlJsonObj = {}
  22. maxLinksPerPageOption = [15, 25, 50]
  23. oldMovieImgUrlJsonFile = ['MovieImgUrl.json', 'MovieImgUrl_V1.json']
  24. def TV():
  25. #addDir('TV SHOWS','http://www.filmitown.com/forums/forumdisplay.php?f=18',1,os.path.join(xbmc.translatePath( artPath ), "TV_Shows_V1.png"))
  26. addDir('MOVIES', 'http://www.sominaltvtheater.com/', 20, os.path.join(xbmc.translatePath(artPath), "Movies_V1.png"))
  27. addDir('MUSIC VIDEOS', 'http://www.sominaltvtheater.com/', 40, os.path.join(xbmc.translatePath(artPath), "Music_V1.png"))
  28. addDir('YouTube CHANNELS', 'http://www.youtube.com/', 60, os.path.join(xbmc.translatePath(artPath), "YouTube_V1.png"))
  29. #addDir('LIVE TV','LIVE',80,os.path.join(xbmc.translatePath( artPath ), "Live_V1.png"))
  30. #addDir('NEW ADD-ON :: [B]VEOH[/B] [I]beta[/I]', 'http://code.google.com/p/apple-tv2-xbmc/', 50, os.path.join(xbmc.translatePath( artPath ), "AJ_V1.png"))
  31. def WHAT_IS_COMING(url):
  32. d = xbmcgui.Dialog()
  33. d.ok('Do you like this add-on and AJ work?', '', 'DONATE today: \n[B]http://code.google.com/p/apple-tv2-xbmc/[/B]')
  34. def CHANNELS(url):
  35. req = urllib2.Request(url)
  36. 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')
  37. response = urllib2.urlopen(req)
  38. link = response.read()
  39. response.close()
  40. web = ''.join(link.splitlines())
  41. match = re.compile('<td><img src="(.+?)" alt="" border="0" /></td> <td class="alt1Active" align="left" id="(.+?)" style="border-left-width: 0;"> <div> <a href="(.+?)" class="forum-link"><strong>(.+?)</strong></a>').findall(web)
  42. for thumbnail, id, url, name in match:
  43. addDir(unescape(name), 'http://www.filmitown.com/forums/' + unescape(url), 2, 'http://www.filmitown.com/forums/' + thumbnail)
  44. def SHOWS(url):
  45. req = urllib2.Request(url)
  46. 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')
  47. response = urllib2.urlopen(req)
  48. link = response.read()
  49. response.close()
  50. web = ''.join(link.splitlines())
  51. match = re.compile('<div> <a href="(.+?)" class="forum-link"><strong>(?!<font color="blue">)(.+?)</strong></a> </div>').findall(web)
  52. for url, name in match:
  53. newName = unescape(name).replace('<img src="http://www.filmitown.com/forums/forums/images/mainlogo/hot.jpg" border="0">', ' @@HOT@@')
  54. newName = newName.replace('<img src="http://www.filmitown.com/forums/forums/images/mainlogo/hot.jpg" border="0"', ' @@HOT@@')
  55. newName = newName.replace('<img src="http://www.filmitown.com/forums/forums/images/mainlogo/hot.jpg" border=', ' @@HOT@@')
  56. newName = newName.replace('<img src="/forums/images/mainlogo/hot.jpg" border="0">', ' @@HOT@@')
  57. newName = newName.replace('<img src="/forums/images/mainlogo/hot.jpg" border="0"', ' @@HOT@@')
  58. newName = newName.replace('<img src="/forums/images/mainlogo/hot.jpg" border=', ' @@HOT@@')
  59. newName = newName.replace('<img src="http://www.filmitown.com/forums/forums/images/mainlogo/new.gif" border="0">', ' **NEW**')
  60. newName = newName.replace('<img src="http://www.filmitown.com/forums/forums/images/mainlogo/new.gif" border="0"', ' **NEW**')
  61. newName = newName.replace('<img src="http://www.filmitown.com/forums/forums/images/mainlogo/new.gif" border=', ' **NEW**')
  62. newName = newName.replace('<img src="/forums/images/mainlogo/new.jpg" border="0">', ' **NEW**')
  63. newName = newName.replace('<img src="/forums/images/mainlogo/new.gif" border="0">', ' **NEW**')
  64. addDir(newName, 'http://www.filmitown.com/forums/' + unescape(url), 3, '')
  65. match = re.compile('<div> <a href="(.+?)" class="forum-link"><strong><font color="blue">(.+?)</font></strong></a> </div>').findall(web)
  66. if(len(match) != 0):
  67. splitted = match[0][0].split('<a href="')
  68. if(len(splitted) != 0):
  69. archivedLink = splitted[len(splitted) - 1]
  70. addDir('**>>**' + match[0][1] + '**>>**', 'http://www.filmitown.com/forums/' + unescape(archivedLink), 2, '')
  71. def EPISODES(url):
  72. req = urllib2.Request(url)
  73. 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')
  74. response = urllib2.urlopen(req)
  75. link = response.read()
  76. response.close()
  77. web = ''.join(link.splitlines())
  78. match = re.compile('<div> (.+?) <a href="(.+?)" id="thread_title_(.+?)">(.+?)</a>').findall(web)
  79. for extraChars, url, id, name in match:
  80. addDir(unescape(name), 'http://www.filmitown.com/forums/' + unescape(url), 4, '')
  81. #SUPPORT FOR PAGES
  82. web = web.replace('\t', '').split('<td class="tcat" width="100%">Threads in Forum<span class="normal">');
  83. match = re.compile('<td class="alt2"><span class="smallfont" title="Showing results (.+?)"><strong>(.+?)</strong></span></td>').findall(web[0])
  84. if(len(match) != 0):
  85. currentPage = int(match[0][1])
  86. match = re.compile('<td class="alt1" nowrap="nowrap"><a rel="start" class="smallfont" href="(.+?)" title="First Page - Results (.+?)"><strong>&laquo;</strong> First</a></td>').findall(web[0])
  87. if(len(match) != 0):
  88. addDir('<<<< FIRST PAGE <<', 'http://www.filmitown.com/forums/' + unescape(match[0][0]), 3, os.path.join(xbmc.translatePath(artPath), "first-icon.png"))
  89. match = re.compile('<td class="alt1"><a class="smallfont" href="(.+?)" title="Show results (.+?)">(.+?)</a>').findall(web[0])
  90. for url, title, page in match:
  91. thisPage = 0
  92. try:
  93. thisPage = int(page)
  94. except:
  95. continue
  96. if(thisPage < currentPage):
  97. addDir('<<<< PREVIOUS PAGE - ' + page + ' <<', 'http://www.filmitown.com/forums/' + unescape(url), 3, os.path.join(xbmc.translatePath(artPath), "prev-icon.png"))
  98. elif(thisPage > currentPage):
  99. addDir('>> NEXT PAGE - ' + page + ' >>>>', 'http://www.filmitown.com/forums/' + unescape(url), 3, os.path.join(xbmc.translatePath(artPath), "next-icon.png"))
  100. match = re.compile('<td class="alt1" nowrap="nowrap"><a class="smallfont" href="(.+?)" title="Last Page - Results (.+?)">Last <strong>&raquo;</strong></a></td>').findall(web[0])
  101. if(len(match) != 0):
  102. addDir('>> LAST PAGE >>>>', 'http://www.filmitown.com/forums/' + unescape(match[0][0]), 3, os.path.join(xbmc.translatePath(artPath), "last-icon.png"))
  103. def PARTS(url):
  104. req = urllib2.Request(url)
  105. 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')
  106. response = urllib2.urlopen(req)
  107. link = response.read()
  108. response.close()
  109. web = ''.join(link.splitlines())
  110. web = web.replace('</div><br />', '</div><br /><br />')
  111. web = web.replace('color="red"', 'color="Red"')
  112. web = web.replace('*DVD Quality* (DailyMotion)</b>', 'DailyMotion *DVD Quality*:-</b>')
  113. web = web.replace('<font color="Red"><b>', '<b><font color="Red">')
  114. web = web.replace('</b></font>', '</font></b>')
  115. web = web.replace('<br />Watch Online', '<b>Watch Online')
  116. web = web.replace('Online/Download', 'Online')
  117. match = re.compile('<b>Watch Online (.+?):(.+?)</b><br />(.+?)<br /><br />').findall(web)
  118. if(len(match) != 0):
  119. arr = web.split(match[len(match) - 1][2])
  120. extraMatch = re.compile('<b>Watch Online (.+?):(.+?)</b><br />(.+?)</div>').findall(arr[1])
  121. match.extend(extraMatch)
  122. else:
  123. extraMatch = re.compile('<b>Watch Online (.+?):(.+?)</b><br />(.+?)<br /></div>').findall(web)
  124. match.extend(extraMatch)
  125. extraMatch = re.compile('<b><font color="Red">Watch Online (.+?)</font>(.+?)<br /><br />(.+?)<br /><br />').findall(web)
  126. match.extend(extraMatch)
  127. for name, extraChars, links in match:
  128. #print match
  129. matching = re.compile('Part (.+?) : <a href="(.+?)" target="_blank">Watch</a>').findall(links)
  130. playList = ''
  131. i = 1
  132. matchCount = len(matching)
  133. for part, url in matching:
  134. addPlayableLink(unescape(name) + ' - Part: ' + part, unescape(url), 13, '')
  135. playList = playList + unescape(url)
  136. if(i < matchCount):
  137. playList = playList + ':;'
  138. i = i + 1
  139. if(i > matchCount and matchCount > 0):
  140. addPlayListLink('[B]Direct PLAY - ' + unescape(name) + '[/B] [I]Playlist of above ' + str(matchCount) + ' videos[/I]', playList, 6, '')
  141. if(matchCount == 0):
  142. extraMatch = re.compile('<a href="http://www.hostingcup.com/(.+?)" target="_blank">(.+?)</a>').findall(links)
  143. matchCount = len(extraMatch)
  144. if(matchCount == 1):
  145. addPlayableLink(unescape(name), unescape(extraMatch[0][1]), 13, '')
  146. if(matchCount == 0):
  147. extraMatch = re.compile('<a href="http://hostingbulk.com/(.+?)" target="_blank">(.+?)</a>').findall(links)
  148. matchCount = len(extraMatch)
  149. if(matchCount == 1):
  150. addPlayableLink(unescape(name), unescape(extraMatch[0][1]), 13, '')
  151. def PLAYLIST_VIDEOLINKS(url, name):
  152. #xbmc.executebuiltin("XBMC.Notification(PLease Wait!,Loading video links into XBMC Media Player,5000)")
  153. ok = True
  154. playList = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
  155. playList.clear()
  156. #time.sleep(2)
  157. links = url.split(':;')
  158. pDialog = xbmcgui.DialogProgress()
  159. ret = pDialog.create('Loading playlist...')
  160. totalLinks = len(links)
  161. loadedLinks = 0
  162. remaining_display = 'Videos loaded :: [B]' + str(loadedLinks) + ' / ' + str(totalLinks) + '[/B] into XBMC player playlist.'
  163. pDialog.update(0, 'Please wait for the process to retrieve video link.', remaining_display)
  164. for videoLink in links:
  165. loadVideos(videoLink, name, True, True)
  166. loadedLinks = loadedLinks + 1
  167. percent = (loadedLinks * 100) / totalLinks
  168. #print percent
  169. remaining_display = 'Videos loaded :: [B]' + str(loadedLinks) + ' / ' + str(totalLinks) + '[/B] into XBMC player playlist.'
  170. pDialog.update(percent, 'Please wait for the process to retrieve video link.', remaining_display)
  171. if (pDialog.iscanceled()):
  172. return False
  173. xbmcPlayer = xbmc.Player()
  174. xbmcPlayer.play(playList)
  175. if not xbmcPlayer.isPlayingVideo():
  176. d = xbmcgui.Dialog()
  177. d.ok('INVALID VIDEO PLAYLIST', 'The playlist videos were removed due to copyright issue.', 'Check other links.')
  178. return ok
  179. def LOAD_AND_PLAY_VIDEO(url, name):
  180. ok = True
  181. print url
  182. videoUrl = loadVideos(url, name, True, False)
  183. if videoUrl == None:
  184. d = xbmcgui.Dialog()
  185. d.ok('NO VIDEO FOUND', 'This video was removed due to copyright issue.', 'Check other links.')
  186. return False
  187. xbmcPlayer = xbmc.Player()
  188. xbmcPlayer.play(videoUrl)
  189. return ok
  190. def VIDEOLINKS(url, name):
  191. loadVideos(url, name, False, False)
  192. def loadVideos(url, name, isRequestForURL, isRequestForPlaylist):
  193. LinkFill = True
  194. print url
  195. #DAILYMOTION
  196. try:
  197. p = re.compile('/daily.php\?url\=(.+?)&AJ;')
  198. match = p.findall(url + '&AJ;')
  199. link = 'http://www.dailymotion.com/video/' + str(match[0])
  200. req = urllib2.Request(link)
  201. 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')
  202. response = urllib2.urlopen(req)
  203. link = response.read()
  204. response.close()
  205. sequence = re.compile('"sequence", "(.+?)"').findall(link)
  206. newseqeunce = urllib.unquote(sequence[0]).decode('utf8').replace('\\/', '/')
  207. imgSrc = re.compile('og:image" content="(.+?)"').findall(link)
  208. if(len(imgSrc) == 0):
  209. imgSrc = re.compile('/jpeg" href="(.+?)"').findall(link)
  210. dm_low = re.compile('"sdURL":"(.+?)"').findall(newseqeunce)
  211. dm_high = re.compile('"hqURL":"(.+?)"').findall(newseqeunce)
  212. if(isRequestForURL):
  213. videoUrl = ''
  214. if(len(dm_high) == 0):
  215. videoUrl = dm_low[0]
  216. else:
  217. videoUrl = dm_high[0]
  218. if(isRequestForPlaylist):
  219. liz = xbmcgui.ListItem('EPISODE', thumbnailImage=imgSrc[0])
  220. playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
  221. playlist.add(url=videoUrl, listitem=liz)
  222. return videoUrl
  223. else:
  224. return videoUrl
  225. else:
  226. if(len(dm_low) > 0):
  227. addLink ('PLAY Standard Quality ', dm_low[0], imgSrc[0])
  228. if(len(dm_high) > 0):
  229. addLink ('PLAY High Quality ', dm_high[0], imgSrc[0])
  230. except: pass
  231. #YOUTUBE
  232. try:
  233. p = re.compile('/yt.php\?url\=(.+?)&AJ;')
  234. match = p.findall(url + '&AJ;')
  235. print match
  236. code = match[0]
  237. linkImage = 'http://i.ytimg.com/vi/' + code + '/default.jpg'
  238. req = urllib2.Request('http://www.youtube.com/watch?v=' + code + '&fmt=18')
  239. 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')
  240. response = urllib2.urlopen(req)
  241. link = response.read()
  242. response.close()
  243. if len(re.compile('shortlink" href="http://youtu.be/(.+?)"').findall(link)) == 0:
  244. if len(re.compile('\'VIDEO_ID\': "(.+?)"').findall(link)) == 0:
  245. req = urllib2.Request('http://www.youtube.com/get_video_info?video_id=' + code + '&asv=3&el=detailpage&hl=en_US')
  246. 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')
  247. response = urllib2.urlopen(req)
  248. link = response.read()
  249. response.close()
  250. map = None
  251. link = link.replace('\\u0026', '&')
  252. match = re.compile('url_encoded_fmt_stream_map=(.+?)&').findall(link)
  253. if len(match) == 0:
  254. map = (re.compile('url_encoded_fmt_stream_map": "(.+?)"').findall(link)[0]).replace('\\/', '/').split('url=')
  255. else:
  256. map = urllib.unquote(match[0]).decode('utf8').split('url=')
  257. if re.search('status=fail', link):
  258. return
  259. if map == None:
  260. return
  261. #print map
  262. highResoVid = ''
  263. youtubeVideoQual = fbn.getSetting('videoQual')
  264. for attr in map:
  265. if attr == '':
  266. continue
  267. parts = attr.split('&qual')
  268. url = urllib.unquote(parts[0]).decode('utf8')
  269. print url
  270. qual = re.compile('&itag=(\d*)').findall(url)[0]
  271. print qual
  272. if(qual == '13'):
  273. if(not(isRequestForURL)):
  274. addLink ('PLAY 3GP Low Quality - 176x144', url, linkImage)
  275. elif(highResoVid == ''):
  276. highResoVid = url
  277. if(qual == '17'):
  278. if(not(isRequestForURL)):
  279. addLink ('PLAY 3GP Medium Quality - 176x144', url, linkImage)
  280. elif(highResoVid == ''):
  281. highResoVid = url
  282. if(qual == '36'):
  283. if(not(isRequestForURL)):
  284. addLink ('PLAY 3GP High Quality - 320x240', url, linkImage)
  285. elif(highResoVid == ''):
  286. highResoVid = url
  287. if(qual == '5'):
  288. if(not(isRequestForURL)):
  289. addLink ('PLAY FLV Low Quality - 400\\327226', url, linkImage)
  290. elif(highResoVid == ''):
  291. highResoVid = url
  292. if(qual == '34'):
  293. if(not(isRequestForURL)):
  294. addLink ('PLAY FLV Medium Quality - 480x360', url, linkImage)
  295. elif(highResoVid == ''):
  296. highResoVid = url
  297. if(qual == '6'):
  298. if(not(isRequestForURL)):
  299. addLink ('PLAY FLV Medium Quality - 640\\327360', url, linkImage)
  300. elif(highResoVid == ''):
  301. highResoVid = url
  302. if(qual == '35'):
  303. if(not(isRequestForURL)):
  304. addLink ('PLAY FLV High Quality - 854\\327480', url, linkImage)
  305. else:
  306. highResoVid = url
  307. if(qual == '18'):
  308. if(not(isRequestForURL)):
  309. addLink ('PLAY MP4 High Quality - 480x360', url, linkImage)
  310. else:
  311. highResoVid = url
  312. if(qual == '22'):
  313. if(not(isRequestForURL)):
  314. addLink ('PLAY MP4 High Quality - 1280x720', url, linkImage)
  315. else:
  316. highResoVid = url
  317. if youtubeVideoQual == '1' or youtubeVideoQual == '2':
  318. break
  319. if(qual == '37'):
  320. if(not(isRequestForURL)):
  321. addLink ('PLAY MP4 High-2 Quality - 1920x1080', url, linkImage)
  322. else:
  323. highResoVid = url
  324. if youtubeVideoQual == '2':
  325. break
  326. if(qual == '38'):
  327. if(not(isRequestForURL)):
  328. addLink ('PLAY MP4 Epic Quality - 4096\\3272304', url, linkImage)
  329. else:
  330. highResoVid = url
  331. if youtubeVideoQual == '2':
  332. break
  333. if(qual == '43'):
  334. if(not(isRequestForURL)):
  335. addLink ('PLAY WEBM Medium Quality - 4096\\3272304', url, linkImage)
  336. else:
  337. highResoVid = url
  338. if(qual == '44'):
  339. if(not(isRequestForURL)):
  340. addLink ('PLAY WEBM High Quality - 4096\\3272304', url, linkImage)
  341. else:
  342. highResoVid = url
  343. if youtubeVideoQual == '1' or youtubeVideoQual == '2':
  344. break
  345. if(qual == '45'):
  346. if(not(isRequestForURL)):
  347. addLink ('PLAY WEBM High-2 Quality - 4096\\3272304', url, linkImage)
  348. else:
  349. highResoVid = url
  350. if youtubeVideoQual == '2':
  351. break
  352. print highResoVid
  353. if(isRequestForURL):
  354. if(isRequestForPlaylist):
  355. liz = xbmcgui.ListItem('VIDEO PART', thumbnailImage=linkImage)
  356. xbmc.PlayList(xbmc.PLAYLIST_VIDEO).add(url=highResoVid, listitem=liz)
  357. return highResoVid
  358. else:
  359. return highResoVid
  360. except: pass
  361. #Z-SHARE
  362. try:
  363. p = re.compile('/watch.php\?url\=(.+?)/')
  364. match = p.findall(url)
  365. url = 'http://www.zshare.net/video/' + match[0]
  366. req = urllib2.Request(url)
  367. 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')
  368. response = urllib2.urlopen(req)
  369. link = response.read()
  370. response.close()
  371. match = re.compile('iframe src\="http://www.zshare.net/videoplayer(.+?)"').findall(link)
  372. req = urllib2.Request('http://www.zshare.net/videoplayer' + match[0].replace(' ', '%20'))
  373. 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')
  374. response = urllib2.urlopen(req)
  375. link = response.read()
  376. response.close()
  377. videoUrl = re.compile('file: "(.+?)"').findall(link)[0]
  378. videoUrl = videoUrl.replace(' ', '%20') + '|User-Agent=' + urllib.quote_plus('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_1) AppleWebKit/534.48.3 (KHTML, like Gecko) Version/5.1 Safari/534.48.3' + '&Accept=' + urllib.quote_plus('text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8') + '&Accept_Encoding=' + urllib.quote_plus('gzip, deflate'))
  379. if(isRequestForURL):
  380. if(isRequestForPlaylist):
  381. liz = xbmcgui.ListItem('EPISODE', thumbnailImage='')
  382. xbmc.PlayList(xbmc.PLAYLIST_VIDEO).add(url=videoUrl, listitem=liz)
  383. return videoUrl
  384. else:
  385. return videoUrl
  386. else:
  387. addLink ('PLAY High Quality Video', videoUrl, '')
  388. except: pass
  389. #HOSTING CUP
  390. try:
  391. chkUrl = url + '&AJ;'
  392. id = re.compile('http://www.hostingcup.com/(.+?)&AJ;').findall(chkUrl)[0]
  393. url = 'http://www.hostingcup.com/' + id
  394. webLink = ''.join(link.splitlines()).replace('\t', '')
  395. #Trying to find out easy way out :)
  396. paramSet = re.compile("return p\}\(\'(.+?)\',36,(.+?),\'(.+?)\'").findall(webLink)
  397. result = parseValue(paramSet[0][0], 36, int(paramSet[0][1]), paramSet[0][2].split('|'))
  398. result = result.replace('\\', '').replace('"', '\'')
  399. print result
  400. imgUrl = re.compile("s1.addVariable\(\'image\',\'(.+?)\'\);").findall(result)[0]
  401. videoUrl = re.compile("s1.addVariable\(\'file\',\'(.+?)\'\);").findall(result)[0]
  402. print 'HOSTING CUP url = ' + videoUrl
  403. if(isRequestForURL):
  404. if(isRequestForPlaylist):
  405. liz = xbmcgui.ListItem(name, thumbnailImage=imgUrl)
  406. playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
  407. playlist.add(url=videoUrl, listitem=liz)
  408. return videoUrl
  409. else:
  410. return videoUrl
  411. else:
  412. addLink ('[B]PLAY VIDEO[/B]: ' + name, videoUrl, imgUrl)
  413. except: pass
  414. #HOSTING BULK
  415. try:
  416. chkUrl = url + '&AJ;'
  417. id = re.compile('http://hostingbulk.com/(.+?)&AJ;').findall(chkUrl)[0]
  418. url = 'http://hostingbulk.com/' + id
  419. webLink = ''.join(link.splitlines()).replace('\t', '')
  420. #Trying to find out easy way out :)
  421. paramSet = re.compile("return p\}\(\'(.+?)\',36,(.+?),\'(.+?)\'").findall(webLink)
  422. result = parseValue(paramSet[0][0], 36, int(paramSet[0][1]), paramSet[0][2].split('|'))
  423. result = result.replace('\\', '').replace('"', '\'')
  424. print result
  425. imgUrl = re.compile("s1.addVariable\(\'image\',\'(.+?)\'\);").findall(result)[0]
  426. videoUrl = re.compile("s1.addVariable\(\'file\',\'(.+?)\'\);").findall(result)[0]
  427. print 'HOSTING BULK url = ' + videoUrl
  428. if(isRequestForURL):
  429. if(isRequestForPlaylist):
  430. liz = xbmcgui.ListItem(name, thumbnailImage=imgUrl)
  431. playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
  432. playlist.add(url=videoUrl, listitem=liz)
  433. return videoUrl
  434. else:
  435. return videoUrl
  436. else:
  437. addLink ('[B]PLAY VIDEO[/B]: ' + name, videoUrl, imgUrl)
  438. except: pass
  439. #MOVIES
  440. def MOVIES_MENU(url, name):
  441. addDir('*[B]High Definition[/B]* Collection', 'http://www.sominaltvtheater.com/2010/11/bluray-movies-collection.html', 21, os.path.join(xbmc.translatePath(artPath), "HD_Movies_V1.png"))
  442. addDir('[B]HINDI[/B] MOVIES', 'http://www.sominaltvtheater.com/2010/11/hindi-movies.html', 23, os.path.join(xbmc.translatePath(artPath), "Hindi_Movies_V1.png"))
  443. addDir('[B]TELUGU[/B] MOVIES', 'http://www.sominaltvtheater.com/2010/11/telugu-movies.html', 24, os.path.join(xbmc.translatePath(artPath), "Telugu_Movies_V1.png"))
  444. addDir('[B]TAMIL[/B] MOVIES', 'http://www.sominaltvtheater.com/2010/11/tamil-movies.html', 25, os.path.join(xbmc.translatePath(artPath), "Tamil_Movies_V1.png"))
  445. # addDir('[B]HINDI[/B] MOVIES','hindi',22,os.path.join(xbmc.translatePath( artPath ), "Hindi_Movies_V1.png"))
  446. # addDir('[B]TELUGU[/B] MOVIES','telugu',22,os.path.join(xbmc.translatePath( artPath ), "Telugu_Movies_V1.png"))
  447. # addDir('[B]TAMIL[/B] MOVIES','tamil',22,os.path.join(xbmc.translatePath( artPath ), "Tamil_Movies_V1.png"))
  448. # addDir('[B]MALAYALAM[/B] MOVIES','malayalam',22,os.path.join(xbmc.translatePath( artPath ), "Malayalam_Movies_V1.png"))
  449. # addDir('[B]KANNADA[/B] MOVIES','kannada',22,os.path.join(xbmc.translatePath( artPath ), "Kannada_Movies_V1.png"))
  450. # addDir('[B]BENGALI[/B] MOVIES','bengali',22,os.path.join(xbmc.translatePath( artPath ), "Bengali_Movies_V1.png"))
  451. # addDir('[B]MARATHI[/B] MOVIES','marathi',22,os.path.join(xbmc.translatePath( artPath ), "Marathi_Movies_V1.png"))
  452. #BharatMovies
  453. def BM_MOVIES_BY_LANG(lang, name):
  454. url = 'http://www.bharatmovies.com/' + lang + '/watch/movies.htm'
  455. req = urllib2.Request(url)
  456. 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')
  457. response = urllib2.urlopen(req)
  458. link = response.read()
  459. response.close()
  460. link = ''.join(link.splitlines()).replace('\t', '').replace('ilactive', 'ila')
  461. index = re.compile('<a id=ila href=(.+?)>(.+?)</a>').findall(link)
  462. indexCount = len(index)
  463. if indexCount > 0:
  464. indexURL = ''
  465. i = 0
  466. for indexLink, indexChar in index:
  467. print indexChar + ' <--> ' + indexLink
  468. indexURL = indexURL + indexChar + '<-->' + 'http://www.bharatmovies.com/' + lang + '/watch/' + indexLink
  469. i = i + 1
  470. if i < indexCount:
  471. indexURL = indexURL + '&AJ;'
  472. addDir('A-Z DIRECTORIES', indexURL, 26, os.path.join(xbmc.translatePath(artPath), "AZ_Dir_V1.png"))
  473. if re.search('Movie Index By Release Year', link):
  474. addDir('Browse by RELEASE DECADES', lang, 27, os.path.join(xbmc.translatePath(artPath), "Release_Decades_V1.png"))
  475. if lang == 'hindi':
  476. addDir('Browse MORE [B]HINDI[/B] MOVIES', 'http://www.sominaltvtheater.com/2010/11/hindi-movies.html', 23, os.path.join(xbmc.translatePath(artPath), "Hindi_Movies_V1.png"))
  477. elif lang == 'telugu':
  478. addDir('Browse MORE [B]TELUGU[/B] MOVIES', 'http://www.sominaltvtheater.com/2010/11/telugu-movies.html', 24, os.path.join(xbmc.translatePath(artPath), "Telugu_Movies_V1.png"))
  479. elif lang == 'tamil':
  480. addDir('Browse MORE [B]TAMIL[/B] MOVIES', 'http://www.sominaltvtheater.com/2010/11/tamil-movies.html', 25, os.path.join(xbmc.translatePath(artPath), "Tamil_Movies_V1.png"))
  481. else:
  482. xbmc.executebuiltin("XBMC.Notification(PLease Wait!,Loading ALL MOVIES in this category,5000)")
  483. BM_LIST(url, name)
  484. def BM_MOVIES_A_Z_DIR(indexMap, name):
  485. indexNameList = []
  486. indexUrlList = []
  487. indexEntries = indexMap.split('&AJ;')
  488. for indexEntry in indexEntries:
  489. index = indexEntry.split('<-->')
  490. #imgUrl = os.path.join(xbmc.translatePath( artPath ), "alpha/red-"+index[0]+".png")
  491. indexNameList.append('[B]' + index[0] + '[/B]')
  492. indexUrlList.append(index[1])
  493. #if index[0] == '#':
  494. # imgUrl = os.path.join(xbmc.translatePath( artPath ), "alpha/red-hash.png")
  495. #addDir(index[0], index[1], 28, imgUrl)
  496. d = xbmcgui.Dialog()
  497. indexSelect = d.select('A-Z Directories:', indexNameList)
  498. if indexSelect == -1:
  499. indexSelect = 0
  500. url = indexUrlList[indexSelect]
  501. name = indexNameList[indexSelect]
  502. BM_LIST(url, name)
  503. def BM_MOVIES_BY_DECADES(lang, name):
  504. indexNameList = []
  505. indexUrlList = []
  506. url = 'http://www.bharatmovies.com/' + lang + '/watch/' + lang + '-movies-new.htm'
  507. req = urllib2.Request(url)
  508. 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')
  509. response = urllib2.urlopen(req)
  510. link = response.read()
  511. response.close()
  512. link = ''.join(link.splitlines()).replace('\t', '').replace('ilactive', 'ila')
  513. index = re.compile('<a id=ila href=(.+?)>(.+?)</a>').findall(link)
  514. for indexLink, indexChar in index:
  515. print indexChar + ' <--> ' + indexLink
  516. indexUrl = 'http://www.bharatmovies.com/' + lang + '/watch/' + indexLink
  517. indexNameList.append('[B]' + indexChar + '[/B]')
  518. indexUrlList.append(indexUrl)
  519. #addDir(indexChar, indexUrl, 28, '')
  520. d = xbmcgui.Dialog()
  521. indexSelect = d.select('Decades:', indexNameList)
  522. if indexSelect == -1:
  523. indexSelect = 0
  524. url = indexUrlList[indexSelect]
  525. name = indexNameList[indexSelect]
  526. BM_LIST(url, name)
  527. def BM_LIST(url, name):
  528. req = urllib2.Request(url)
  529. 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')
  530. response = urllib2.urlopen(req)
  531. link = response.read()
  532. response.close()
  533. link = ''.join(link.splitlines()).replace('\t', '').replace('ilactive', 'ila').replace('<i>', '').replace('</i>', '')
  534. movies = re.compile('<div id=L[1,2]><a href=(.+?)>(.+?)</a><span>(.+?)</span></div>').findall(link)
  535. if len(movies) > 0 and fbn.getSetting('load_image_from_tmdb') == 'true':
  536. xbmc.executebuiltin("XBMC.Notification(PLease Wait!,Loading MOVIE image from themoviedb.org, Check add-on settings for more information, 5000)")
  537. for movieLink, movieName, movieCast in movies:
  538. movieNameParts = re.compile('(.+?)<font color=red>(.+?)</font>').findall(movieName)
  539. if len(movieNameParts) > 0:
  540. movieName = movieNameParts[0][0] + ' ' + movieNameParts[0][1]
  541. #print movieName + ' --> '+movieLink + ' -->CASTING--> '+movieCast
  542. movieLink = url[0 : url.rindex('/') + 1] + movieLink
  543. addDirAndLoadImg(movieName, movieLink, 29)
  544. def BM_VIDEO_SOURCES(url, name):
  545. req = urllib2.Request(url)
  546. 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')
  547. response = urllib2.urlopen(req)
  548. link = response.read()
  549. response.close()
  550. link = ''.join(link.splitlines()).replace('\t', '')
  551. sourceNames = re.compile('<br> Source: [2,3,4,5,6,7,8,9,10] <br>').findall(link)
  552. sourceNames.append('<br> Source: 1 <br>')
  553. sourceVideoLinks = link.split('<br> Source:')
  554. partHeading = 'Part'
  555. if re.search('/songs/', url):
  556. partHeading = 'Song'
  557. index = 0
  558. sourceNbr = 1
  559. for sourceName in sourceNames:
  560. try:
  561. sourceName = re.compile('<div id=source>Source: (.+?)</div>').findall(sourceVideoLinks[index])[0]
  562. except:
  563. index = index + 1
  564. continue
  565. print sourceName
  566. if sourceName == 'YouKu' or sourceName == 'Rajshri':
  567. index = index + 1
  568. xbmc.executebuiltin("XBMC.Notification(Skipped Source: YouKu,Not yet supported,5000)")
  569. continue
  570. sourceVideos = re.compile('<embed(.+?)>').findall(sourceVideoLinks[index])
  571. matchCount = len(sourceVideos)
  572. if matchCount == 1:
  573. try:
  574. if re.search('http://www.youtube.com/p/', sourceVideos[0]):
  575. videoLink = sourceVideos[0] + '&'
  576. playlistID = re.compile('http://www.youtube.com/p/(.+?)&').findall(videoLink)[0]
  577. print 'retreiveYouTubePlayList ' + playlistID
  578. retreiveYouTubePlayList(playlistID, '', 'Source #' + str(sourceNbr) + ' ' + sourceName, 'Part')
  579. sourceNbr = sourceNbr + 1
  580. index = index + 1
  581. continue
  582. elif re.search('http://www.youtube.com/view_play_list', videoLink):
  583. videoLink = sourceVideos[0] + '&'
  584. playlistID = re.compile('http://www.youtube.com/view_play_list\?p=(.+?)&').findall(videoLink)[0]
  585. print 'retreiveYouTubePlayList ' + playlistID
  586. retreiveYouTubePlayList(playlistID, '', 'Source #' + str(sourceNbr) + ' ' + sourceName, 'Part')
  587. sourceNbr = sourceNbr + 1
  588. index = index + 1
  589. continue
  590. except: pass
  591. if matchCount > 1:
  592. playList = ''
  593. i = 1
  594. for sourceVideo in sourceVideos:
  595. sourceVideo = re.compile(' src=(.+?) ').findall(' ' + sourceVideo + ' ')[0].replace('\'', '').replace('"', '')
  596. addPlayableMovieLink('Source #' + str(sourceNbr) + ' ' + sourceName + ' - ' + partHeading + ': ' + str(i), unescape(sourceVideo), 31, '')
  597. playList = playList + unescape(sourceVideo)
  598. if(i < matchCount):
  599. playList = playList + ':;'
  600. i = i + 1
  601. if(i > matchCount and matchCount > 0):
  602. addPlayListLink('[B]Direct PLAY - ' + sourceName + '[/B] [I]Playlist of above ' + str(matchCount) + ' videos[/I]', playList, 32, '')
  603. else:
  604. sourceVideo = re.compile(' src=(.+?) ').findall(' ' + sourceVideos[0] + ' ')[0].replace('\'', '').replace('"', '')
  605. addPlayableMovieLink('[B]SINGLE LINK[/B] Source #' + str(sourceNbr) + ' ' + sourceName, unescape(sourceVideo), 31, '')
  606. sourceNbr = sourceNbr + 1
  607. index = index + 1
  608. #SominalTVTheater
  609. def MORE_MOVIES_HINDI(url, name):
  610. MoviesList(url, 30)
  611. def MORE_MOVIES_TELUGU(url, name):
  612. MoviesList(url, 30)
  613. def MORE_MOVIES_TAMIL(url, name):
  614. MoviesList(url, 30)
  615. def MOVIES_BLURAY(url, name):
  616. BlurayMoviesList(url)
  617. def BlurayMoviesList(url):
  618. req = urllib2.Request(url)
  619. 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')
  620. response = urllib2.urlopen(req)
  621. link = response.read()
  622. response.close()
  623. link = ''.join(link.splitlines()).replace('\t', '').replace('\'', '"').replace('&nbsp;', '')
  624. moviesContentArray = re.compile('<div class="cover"><div class="entry">(.+?)<div style="clear:both;"></div><div class="clear"></div>').findall(link)
  625. moviesArray = re.compile('<a href="(.+?)"><img alt="" class="ethumb" src="(.+?)" style="cursor: move;" /></a>').findall(moviesContentArray[0])
  626. movieIndex = 1
  627. for movieLink, movieImg in moviesArray:
  628. #movieTitle = 'MOVIE #' + str(movieIndex)
  629. movieTitle = movieLink[movieLink.rindex('/') + 1 : movieLink.rindex('.')]
  630. addDir(unescape(movieTitle), movieLink, 30, movieImg)
  631. movieIndex = movieIndex + 1
  632. def MoviesList(url, mode):
  633. req = urllib2.Request(url)
  634. 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')
  635. response = urllib2.urlopen(req)
  636. link = response.read()
  637. response.close()
  638. link = ''.join(link.splitlines()).replace('\t', '').replace('\'', '"').replace('&nbsp;', '')
  639. moviesContentArray = re.compile('<br /><br />(.+?)<div class="clear"></div>').findall(link)
  640. if(len(moviesContentArray) == 0):
  641. moviesContentArray = re.compile('</div><br /><div style="text-align: center;">(.+?)<div style="clear:both;"></div>').findall(link)
  642. moviesContent = moviesContentArray[0]
  643. moviesContent = moviesContent.replace('<a href="http://adf.ly/377117/http://www.sominaltvtheater.com/2010/11/bluray-movies-collection.html"><b>(Hindi, Telugu, &amp; Tamil)</b></a>', '')
  644. moviesContent = moviesContent.replace('<span class="Apple-style-span" style="font-size: xx-small;"></span>', '')
  645. moviesContent = moviesContent.replace('<a href="http://www.sominaltvtheater.com/2010/11/apaharan-2005-bluray.html"></a>', '')
  646. moviesContent = moviesContent.replace('</a><a href="http://www.sominaltvtheater.com/2011/04/teen-thay-bhai-2011-dvdscr.html">', '')
  647. moviesContent = moviesContent.replace('</a><span class="Apple-style-span" style="color: blue; font-size: xx-small;">*BluRay*</span>', ' *BluRay*</a>')
  648. moviesContent = moviesContent.replace('</a><b><span class="Apple-style-span" style="color: blue; font-size: xx-small;">*BluRay*</span></b>', ' *BluRay*</a>')
  649. moviesContent = moviesContent.replace('</a><b><span class="Apple-style-span" style="color: blue; font-size: xx-small;">*HD*</span></b>', ' *HD*</a>')
  650. moviesContent = moviesContent.replace('</a><span class="Apple-style-span" style="font-size: xx-small;">DVD</span>', ' ~DVD~</a>')
  651. moviesContent = moviesContent.replace('</a><span class="Apple-style-span" style="font-size: xx-small;">DVDSCR</span>', ' --DVDSCR--</a>')
  652. moviesContent = moviesContent.replace('</a><span class="Apple-style-span" style="font-size: xx-small;">TS</span>', ' --TS--</a>')
  653. moviesContent = moviesContent.replace('</a><span class="Apple-style-span" style="font-size: xx-small;">TC</span>', ' --TC--</a>')
  654. moviesContent = moviesContent.replace('</a><span class="Apple-style-span" style="font-size: xx-small;">DVD <span class="Apple-style-span" style="color: blue;"><b>*HD*</b></span></span>', ' *HD*</a>')
  655. moviesContent = moviesContent.replace('</a><b><span class="Apple-style-span" style="color: blue; font-size: xx-small;">Telugu</span></b>', ' (Telugu)</a>')
  656. moviesContent = moviesContent.replace('</a><b><span class="Apple-style-span" style="color: blue; font-size: xx-small;">Tamil</span></b>', ' (Tamil)</a>')
  657. moviesContent = moviesContent.replace('</a><a href="http://www.sominaltvtheater.com/2011/05/laaga-chunari-mein-daag-2007-dvd.html">', '')
  658. moviesContent = moviesContent.replace('></a>', '>SKIP ME</a>')
  659. movies = re.compile('<a href="(.+?)">(.+?)</a>').findall(moviesContent)
  660. i = 0
  661. for movieLink, movieTitle in movies:
  662. if movieTitle == 'SKIP ME':
  663. continue
  664. if re.search('Hindi, Telugu, & Tamil', unescape(movieTitle)) or re.search('<b>\(Click Here\)</b>', unescape(movieTitle)):
  665. continue
  666. if movieTitle == '*HD*' or movieTitle == '(Click Here)':
  667. continue
  668. i = i + 1
  669. #print str(i) + ': ' + movieTitle + ' LINK = ' + movieLink.replace('" target="_blank','')
  670. addDirAndLoadImg(unescape(movieTitle), movieLink.replace('" target="_blank', ''), mode)
  671. xbmcplugin.setContent(handle=int(sys.argv[1]), content='movies')
  672. def MOVIE_VIDEO_PARTS(url, name):
  673. if re.search('http://www.youtube.com/', url):
  674. url = url.replace('?&amp;', '?').replace('?f&amp;', '?').replace('?f&', '?').replace('?&', '?') + '&'
  675. playlistID = re.compile('http://www.youtube.com/view_play_list\?p=(.+?)&').findall(url)[0]
  676. print ' ALREADY GOT DIRECT URL retreiveYouTubePlayList ' + playlistID
  677. retreiveYouTubePlayList(playlistID, '', name, 'Part')
  678. return
  679. print url
  680. req = urllib2.Request(url)
  681. 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')
  682. response = urllib2.urlopen(req)
  683. link = response.read()
  684. response.close()
  685. link = ''.join(link.splitlines()).replace('\t', '').replace('\'', '"').replace('<b><b>', '<b>').replace('</b></b>', '</b>').replace(' font-weight: normal;', '')
  686. imgUrl = ''
  687. videoContentLink = re.compile('<div class="cover"><div class="entry">(.+?)<div style="clear:both;"></div><div class="clear"></div>').findall(link)
  688. try:
  689. imgUrl = re.compile('src="(.+?)"').findall(videoContentLink[0])[0]
  690. print imgUrl
  691. except: pass
  692. videoLinkSources = re.compile('<a href="(.+?)">(.+?)</a>').findall(videoContentLink[0])
  693. moreVideoLinks = re.compile('<iframe(.+?)src="(.+?)"(.+?)>').findall(videoContentLink[0])
  694. for temp1, videoLink, temp2 in moreVideoLinks:
  695. videoLinkSources.append([videoLink, 'Full Movie'])
  696. moreVideoLinks = re.compile('<param name="movie" value="(.+?)">').findall(videoContentLink[0])
  697. for videoLink in moreVideoLinks:
  698. videoLinkSources.append([videoLink, 'Full Movie'])
  699. sourcePart = 1
  700. for videoLink, videoName in videoLinkSources:
  701. videoName = videoName.replace('(Click Here)', '')
  702. if re.search('<img', videoName) or videoLink == 'http://www.youtube.com/user/SominalTvTheaters' or re.search('Click Here', videoName):
  703. print "SKIP IMG or unwanted URL"
  704. continue
  705. if re.search('DOWNLOAD', videoName):
  706. videoName = 'Full Movie '
  707. videoLink = videoLink.replace('" target="_blank', '')
  708. sourceName = videoName + ' :: SOURCE# ' + str(sourcePart)
  709. sourcePart = sourcePart + 1
  710. if re.search('http://adf\.ly/', videoLink):
  711. videoLink = videoLink + '&AJ;'
  712. videoLink = re.compile('http://adf.ly/(.+?)/(.+?)&AJ;').findall(videoLink)[0][1]
  713. if not re.search('http://', videoLink):
  714. videoLink = 'http://' + videoLink
  715. if re.search('http://sominaltvmovies', videoLink):
  716. req = urllib2.Request(videoLink)
  717. 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')
  718. response = urllib2.urlopen(req)
  719. link = response.read()
  720. response.close()
  721. link = ''.join(link.splitlines()).replace('\t', '').replace('\'', '"')
  722. videoContent = re.compile('<div class="post-body entry-content">(.+?)<div style="clear: both;"></div>').findall(link)
  723. if(len(videoContent) == 1):
  724. videoParts = re.compile('src="(.+?)"').findall(videoContent[0])
  725. if(len(videoParts) > 1):
  726. i = 1
  727. playList = ''
  728. matchCount = len(videoParts)
  729. for videoPartLink in videoParts:
  730. addPlayableMovieLink(sourceName + ' - Part: ' + str(i), unescape(videoPartLink), 31, imgUrl)
  731. playList = playList + unescape(videoPartLink)
  732. if(i < matchCount):
  733. playList = playList + ':;'
  734. i = i + 1
  735. if(i > matchCount and matchCount > 0):
  736. addPlayListLink('[B]Direct PLAY - ' + sourceName + '[/B] [I]Playlist of above ' + str(matchCount) + ' videos[/I]', playList, 32, imgUrl)
  737. elif(len(videoParts) == 1):
  738. videoPartLink = videoParts[0]
  739. if re.search('http://www.dailymotion.com/widget/jukebox', videoPartLink):
  740. matching = re.compile('\%2Fplaylist\%2F(.+?)&').findall(videoPartLink)
  741. if len(matching) == 0:
  742. continue
  743. playlistID = matching[0]
  744. print 'retreiveDailyMotionPlayList ' + playlistID
  745. retreiveDailyMotionPlayList(playlistID, imgUrl, sourceName, 'Part')
  746. elif re.search('http://www.youtube.com/p/', videoPartLink):
  747. matching = re.compile('http://www.youtube.com/p/(.+?)\?').findall(videoPartLink)
  748. if len(matching) == 0:
  749. continue
  750. playlistID = matching[0]
  751. print 'retreiveYouTubePlayList ' + playlistID
  752. retreiveYouTubePlayList(playlistID, imgUrl, sourceName, 'Part')
  753. else:
  754. addPlayableMovieLink('[B]SINGLE LINK [/B]' + sourceName, unescape(videoPartLink), 31, imgUrl)
  755. else:
  756. if re.search('http://www.dailymotion.com/widget/jukebox', videoLink):
  757. matching = re.compile('\%2Fplaylist\%2F(.+?)&').findall(videoLink)
  758. if len(matching) == 0:
  759. continue
  760. playlistID = matching[0]
  761. print 'retreiveDailyMotionPlayList ' + playlistID
  762. retreiveDailyMotionPlayList(playlistID, imgUrl, sourceName, 'Part')
  763. elif re.search('http://www.dailymotion.com/playlist/', videoLink):
  764. videoLink = videoLink + '&AJ;'
  765. matching = re.compile('http://www.dailymotion.com/playlist/(.+?)&').findall(videoLink)
  766. if len(matching) == 0:
  767. continue
  768. playlistID = matching[0]
  769. print 'retreiveDailyMotionPlayList ' + playlistID
  770. retreiveDailyMotionPlayList(playlistID, imgUrl, sourceName, 'Part')
  771. elif re.search('http://www.youtube.com/p/', videoLink):
  772. matching = re.compile('http://www.youtube.com/p/(.+?)\?').findall(videoLink)
  773. if len(matching) == 0:
  774. continue
  775. playlistID = matching[0]
  776. print 'retreiveYouTubePlayList ' + playlistID
  777. retreiveYouTubePlayList(playlistID, imgUrl, sourceName, 'Part')
  778. elif re.search('http://www.youtube.com/view_play_list', videoLink):
  779. videoLink = videoLink + '&'
  780. matching = re.compile('http://www.youtube.com/view_play_list\?p=(.+?)&').findall(videoLink)
  781. if len(matching) == 0:
  782. continue
  783. playlistID = matching[0]
  784. print 'retreiveYouTubePlayList ' + playlistID
  785. retreiveYouTubePlayList(playlistID, imgUrl, sourceName, 'Part')
  786. else:
  787. addPlayableMovieLink('[B]SINGLE LINK [/B]' + sourceName, unescape(videoLink), 31, imgUrl)
  788. #YOUTUBE
  789. def getVideoTitle(video):
  790. return getText(video.getElementsByTagName("title")[0].childNodes)
  791. def getVideoID(video):
  792. return getText(video.getElementsByTagName("yt:videoid")[0].childNodes)
  793. def getText(nodelist):
  794. rc = []
  795. for node in nodelist:
  796. if node.nodeType == node.TEXT_NODE:
  797. rc.append(node.data)
  798. return ''.join(rc)
  799. #VIMEO
  800. def vimeo_getReqSignature(video):
  801. return getText(video.getElementsByTagName("request_signature")[0].childNodes)
  802. def vimeo_getVidThumb(video):
  803. return getText(video.getElementsByTagName("thumbnail")[0].childNodes)
  804. def vimeo_getQuality(video):
  805. quality = 'sd'
  806. try:
  807. if(getText(video.getElementsByTagName("isHD")[0].childNodes) == '1'):
  808. quality = 'hd'
  809. except: pass
  810. return quality
  811. def vimeo_getReqSignatureExpires(video):
  812. return getText(video.getElementsByTagName("request_signature_expires")[0].childNodes)
  813. def vimeo_getVideoUrl(videoId, reqSig, reqSigExp, qual):
  814. video_url = "http://player.vimeo.com/play_redirect?clip_id=%s&sig=%s&time=%s&quality=%s&codecs=H264,VP8,VP6&type=moogaloop_local&embed_location=" % (videoId, reqSig, reqSigExp, qual)
  815. req = urllib2.Request(video_url)
  816. 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')
  817. response = urllib2.urlopen(req)
  818. video_url = response.geturl()
  819. response.close()
  820. return video_url
  821. def MOVIE_PLAYLIST_VIDEOLINKS(url, name):
  822. #xbmc.executebuiltin("XBMC.Notification(PLease Wait!,Loading video links into XBMC Media Player,5000)")
  823. ok = True
  824. playList = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
  825. playList.clear()
  826. #time.sleep(2)
  827. links = url.split(':;')
  828. pDialog = xbmcgui.DialogProgress()
  829. ret = pDialog.create('Loading playlist...')
  830. totalLinks = len(links)
  831. loadedLinks = 0
  832. remaining_display = 'Videos loaded :: [B]' + str(loadedLinks) + ' / ' + str(totalLinks) + '[/B] into XBMC player playlist.'
  833. pDialog.update(0, 'Please wait for the process to retrieve video link.', remaining_display)
  834. for videoLink in links:
  835. Movie_loadVideos(videoLink, name, True, True)
  836. loadedLinks = loadedLinks + 1
  837. percent = (loadedLinks * 100) / totalLinks
  838. #print percent
  839. remaining_display = 'Videos loaded :: [B]' + str(loadedLinks) + ' / ' + str(totalLinks) + '[/B] into XBMC player playlist.'
  840. pDialog.update(percent, 'Please wait for the process to retrieve video link.', remaining_display)
  841. if (pDialog.iscanceled()):
  842. return False
  843. xbmcPlayer = xbmc.Player()
  844. xbmcPlayer.play(playList)
  845. if not xbmcPlayer.isPlayingVideo():
  846. d = xbmcgui.Dialog()
  847. d.ok('INVALID VIDEO PLAYLIST', 'The playlist videos were removed due to copyright issue.', 'Check other links.')
  848. return ok
  849. def MOVIE_LOAD_AND_PLAY_VIDEO(url, name):
  850. ok = True
  851. print url
  852. xbmc.executebuiltin("XBMC.Notification(PLease Wait!,Loading video link into XBMC Media Player,5000)")
  853. videoUrl = Movie_loadVideos(url, name, True, False)
  854. if videoUrl == None:
  855. d = xbmcgui.Dialog()
  856. d.ok('NO VIDEO FOUND', 'This video was removed due to copyright issue.', 'Check other links.')
  857. return False
  858. xbmcPlayer = xbmc.Player()
  859. xbmcPlayer.play(videoUrl)
  860. return ok
  861. def MOVIE_VIDEOLINKS(url, name):
  862. Movie_loadVideos(url, name, False, False)
  863. def Movie_loadVideos(url, name, isRequestForURL, isRequestForPlaylist):
  864. url = url + '&AJ;'
  865. print 'VIDEO URL = ' + url
  866. #YOUTUBE
  867. try:
  868. match = re.compile('http://www.youtube.com/v/(.+?)&').findall(url)
  869. code = match[0]
  870. linkImage = 'http://i.ytimg.com/vi/' + code + '/default.jpg'
  871. req = urllib2.Request('http://www.youtube.com/watch?v=' + code + '&fmt=18')
  872. 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')
  873. response = urllib2.urlopen(req)
  874. link = response.read()
  875. response.close()
  876. if len(re.compile('shortlink" href="http://youtu.be/(.+?)"').findall(link)) == 0:
  877. if len(re.compile('\'VIDEO_ID\': "(.+?)"').findall(link)) == 0:
  878. req = urllib2.Request('http://www.youtube.com/get_video_info?video_id=' + code + '&asv=3&el=detailpage&hl=en_US')
  879. 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')
  880. response = urllib2.urlopen(req)
  881. link = response.read()
  882. response.close()
  883. map = None
  884. link = link.replace('\\u0026', '&')
  885. match = re.compile('url_encoded_fmt_stream_map=(.+?)&').findall(link)
  886. if len(match) == 0:
  887. map = (re.compile('url_encoded_fmt_stream_map": "(.+?)"').findall(link)[0]).replace('\\/', '/').split('url=')
  888. else:
  889. map = urllib.unquote(match[0]).decode('utf8').split('url=')
  890. if re.search('status=fail', link):
  891. return
  892. if map == None:
  893. return
  894. #print map
  895. highResoVid = ''
  896. youtubeVideoQual = fbn.getSetting('videoQual')
  897. for attr in map:
  898. if attr == '':
  899. continue
  900. parts = attr.split('&qual')
  901. url = urllib.unquote(parts[0]).decode('utf8')
  902. print url
  903. qual = re.compile('&itag=(\d*)').findall(url)[0]
  904. print qual
  905. if(qual == '13'):
  906. if(not(isRequestForURL)):
  907. addLink ('PLAY 3GP Low Quality - 176x144', url, linkImage)
  908. elif(highResoVid == ''):
  909. highResoVid = url
  910. if(qual == '17'):
  911. if(not(isRequestForURL)):
  912. addLink ('PLAY 3GP Medium Quality - 176x144', url, linkImage)
  913. elif(highResoVid == ''):
  914. highResoVid = url
  915. if(qual == '36'):
  916. if(not(isRequestForURL)):
  917. addLink ('PLAY 3GP High Quality - 320x240', url, linkImage)
  918. elif(highResoVid == ''):
  919. highResoVid = url
  920. if(qual == '5'):
  921. if(not(isRequestForURL)):
  922. addLink ('PLAY FLV Low Quality - 400\\327226', url, linkImage)
  923. elif(highResoVid == ''):
  924. highResoVid = url
  925. if(qual == '34'):
  926. if(not(isRequestForURL)):
  927. addLink ('PLAY FLV Medium Quality - 480x360', url, linkImage)
  928. elif(highResoVid == ''):
  929. highResoVid = url
  930. if(qual == '6'):
  931. if(not(isRequestForURL)):
  932. addLink ('PLAY FLV Medium Quality - 640\\327360', url, linkImage)
  933. elif(highResoVid == ''):
  934. highResoVid = url
  935. if(qual == '35'):
  936. if(not(isRequestForURL)):
  937. addLink ('PLAY FLV High Quality - 854\\327480', url, linkImage)
  938. else:
  939. highResoVid = url
  940. if(qual == '18'):
  941. if(not(isRequestForURL)):
  942. addLink ('PLAY MP4 High Quality - 480x360', url, linkImage)
  943. else:
  944. highResoVid = url
  945. if(qual == '22'):
  946. if(not(isRequestForURL)):
  947. addLink ('PLAY MP4 High Quality - 1280x720', url, linkImage)
  948. else:
  949. highResoVid = url
  950. if youtubeVideoQual == '1' or youtubeVideoQual == '2':
  951. break
  952. if(qual == '37'):
  953. if(not(isRequestForURL)):
  954. addLink ('PLAY MP4 High-2 Quality - 1920x1080', url, linkImage)
  955. else:
  956. highResoVid = url
  957. if youtubeVideoQual == '2':
  958. break
  959. if(qual == '38'):
  960. if(not(isRequestForURL)):
  961. addLink ('PLAY MP4 Epic Quality - 4096\\3272304', url, linkImage)
  962. else:
  963. highResoVid = url
  964. if youtubeVideoQual == '2':
  965. break
  966. if(qual == '43'):
  967. if(not(isRequestForURL)):
  968. addLink ('PLAY WEBM Medium Quality - 4096\\3272304', url, linkImage)
  969. else:
  970. highResoVid = url
  971. if(qual == '44'):
  972. if(not(isRequestForURL)):
  973. addLink ('PLAY WEBM High Quality - 4096\\3272304', url, linkImage)
  974. else:
  975. highResoVid = url
  976. if youtubeVideoQual == '1' or youtubeVideoQual == '2':
  977. break
  978. if(qual == '45'):
  979. if(not(isRequestForURL)):
  980. addLink ('PLAY WEBM High-2 Quality - 4096\\3272304', url, linkImage)
  981. else:
  982. highResoVid = url
  983. if youtubeVideoQual == '2':
  984. break
  985. print highResoVid
  986. if(isRequestForURL):
  987. if(isRequestForPlaylist):
  988. liz = xbmcgui.ListItem('VIDEO PART', thumbnailImage=linkImage)
  989. xbmc.PlayList(xbmc.PLAYLIST_VIDEO).add(url=highResoVid, listitem=liz)