Advertisement
Guest User

sansat

a guest
Nov 23rd, 2009
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 22.77 KB | None | 0 0
  1. import urllib,urllib2,re,xbmcplugin,xbmcgui
  2.  
  3. #Filmicity
  4.  
  5. def CATEGORIES():
  6.         addDir('Sony','http://www.filmicity.net/forumdisplay.php?f=19',1,'http://i25.tinypic.com/2d9wm1h.png')
  7.         addDir('Zee','http://www.filmicity.net/forumdisplay.php?f=20',1,'http://i30.tinypic.com/2a9tug6.png')
  8.         addDir('Star One','http://www.filmicity.net/forumdisplay.php?f=21',1,'http://i27.tinypic.com/2w6rwbk.png')
  9.         addDir('Star Plus','http://www.filmicity.net/forumdisplay.php?f=22',1,'http://i31.tinypic.com/97l0s2.png')
  10.         addDir('Colors','http://www.filmicity.net/forumdisplay.php?f=23',1,'http://i26.tinypic.com/if1wfr.png')
  11.         addDir('NDTV Imagine','http://www.filmicity.net/forumdisplay.php?f=24',1,'http://i30.tinypic.com/2lt62p5.png')
  12.         addDir('SAB','http://www.filmicity.net/forumdisplay.php?f=26',1,'http://i25.tinypic.com/v6812r.png')
  13.         addDir('MTV','http://www.filmicity.net/forumdisplay.php?f=53',1,'http://i29.tinypic.com/2n0r2g0.png')
  14.  
  15.  
  16. def PAGES(url):
  17.         req = urllib2.Request(url)
  18.         req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
  19.         response = urllib2.urlopen(req)
  20.         link=response.read()
  21.         response.close()
  22.  
  23.         match=re.compile('<a href="(.+?)" class="forum-link"><strong>(.+?)</strong></a>').findall(link)
  24.         #print match
  25.         #print url
  26.         for url,name in match:
  27.             #url='http://www.filmicity.net/'+url
  28.             url=htmlencode('http://www.filmicity.net/'+url)    
  29.             print url
  30.             print name
  31.             addDir(name,url,2,'')
  32.                            
  33.              
  34. def INDEX(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.                 match=re.compile('<a href="(.+?)" id="(.+?)">(.+?)</a>').findall(link)
  41.                 #print match
  42.                 #print url
  43.                 for url,trash,name in match:
  44.                     url=htmlencode('http://www.filmicity.net/'+url)
  45.                     print url
  46.                     print name
  47.                     addDir(name,url,3,'')
  48.                    
  49.  
  50. def PARTS(url):
  51.                 req = urllib2.Request(url)
  52.                 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')
  53.                 response = urllib2.urlopen(req)
  54.                 link=response.read()
  55.                 response.close()
  56.                 match=re.compile('<a href="(.+?)" target="_blank">(.+?)</a><br />').findall(link)
  57.                 #print match
  58.                 #print url
  59.                 for url,name in match:
  60.                     print url
  61.                     print name
  62.                     addDir(name,url,4,'')
  63.  
  64.                
  65. def VIDEOLINKS(url,name):
  66.                 LinkFill = True
  67.                 req = urllib2.Request(url)
  68.                 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')
  69.                 response = urllib2.urlopen(req)
  70.                 link=response.read()
  71.                 response.close()
  72.                 #VEOH
  73.                 try:
  74.                         p=re.compile('<param name="movie" value="http://www.veoh.com/videodetails.+?permalinkId=(.+?)" />')
  75.                         match=p.findall(link)
  76.                         for a in match:
  77.                                         f=urllib2.urlopen("http://keepvid.com/?url=http://www.veoh.com/videos/"+str(a))
  78.                                         myspace=f.read()
  79.                                         comp=re.compile('</script><br /><br /><a href="redirect.+?(.+?)" class="link" target="_blank">')
  80.                                         for url in comp.findall(myspace):
  81.                                                         addLink ('Play '+name,url,'')
  82.                 except:
  83.                         pass
  84.         #DAILYMOTION
  85.                 try:
  86.                                 daily=re.compile('<param name="movie" value="http://www.dailymotion.com/swf/(.+?)">').findall(link)
  87.                                 req = urllib2.Request('http://www.dailymotion.com/video/%s'%daily[0])
  88.                                 req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14')
  89.                                 response = urllib2.urlopen(req).read()
  90.                                 match=re.compile('url=rev=.+?&lang=en&callback=.+?&preview=.+?&video=(.+?)%40%40spark').findall(response)
  91.                                 addLink('Play '+name,urllib.unquote(match[0]),"")
  92.                                
  93.                 except: pass
  94.                 #MSNSOAPBOX
  95.                 try:
  96.                                 msn=re.compile('<param name="movie" value="http://images.video.msn.com/flash/soapbox1_1.swf.+?=v&.+?;v=(.+?)"/>').findall(link)
  97.                                 for url in msn:
  98.                                                 addLink('Play '+name,'http://soapbox.msn.com/StreamingUrl.aspx?vid='+url+'&t=.flv','')
  99.                 except:
  100.                         pass
  101.                 #GOOGLE
  102.                 try:
  103.                                 google=re.compile('src=\"http://video\.google\.com/googleplayer\.swf\?docId=(.+?)"').findall(link)
  104.                                 print google[0]
  105.                                 req = urllib2.Request("http://video.google.com/videoplay?docid="+str(google[0]))
  106.                                 req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14')
  107.                                 response = urllib2.urlopen(req).read()
  108.                                 match=re.compile('preview_url\:\'/s/zizJPyf32zs/googleplayer\.swf\?videoUrl\\\\x3d(.+?)\\\\x26thumbnailUrl').findall(response)
  109.                                 print match[0]
  110.                                 addLink('Play '+name,urllib.unquote(match[0]),"")
  111.  
  112.                 except:
  113.                         pass
  114.                 try:
  115.                                 p=re.compile('<param name="movie" value="http://video.google.com/googleplayer.swf.+?docId=(.+?)" />')
  116.                                 match=p.findall(link)
  117.                                 for a in match:
  118.                                                 f=urllib2.urlopen("http://www.flashvideodownloader.org/download.php?u=http://video.google.com/videoplay?docid="+str(a))
  119.                                                 myspace=f.read()
  120.                                                 comp=re.compile('<a href="(.+?)" title="Click to Download"><font color=red>')
  121.                                                 for url in comp.findall(myspace):
  122.                                                                 addLink ('Play '+name,url,'')
  123.                 except:
  124.                         pass
  125.                 #YOUTUBE
  126.                 try:
  127.                                 p=re.compile('<embed src="http://www.youtube.com/v/(.+?)&autoplay=1" type="application/x-shockwave-flash" wmode="transparent" width="625" height="515"></embed>')
  128.                                 match=p.findall(link)
  129.                                 for code in match:
  130.                                                 print 'code='+code
  131.                                                 req = urllib2.Request('http://www.youtube.com/watch?v='+code)
  132.                                                 req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14')
  133.                                                 response = urllib2.urlopen(req)
  134.                                                 link=response.read()
  135.                                                 response.close()
  136.                                                 p=re.compile('"t": "(.+?)"')
  137.                                                 match=p.findall(link)
  138.                                                 for blah in match:
  139.                                                                 linkage="http://www.youtube.com/get_video?video_id="+code+"&t="+blah+"&fmt=18"
  140.                                                                 addLink ('Play '+name,linkage,'')
  141.                 except:
  142.                         pass
  143.                 #MYSPACE
  144.                 try:
  145.                                 p=re.compile('<param name="movie" value="http://mediaservices.myspace.com/services/media/embed.aspx/m=(.+?),t=1,mt=video,ap=0" />')
  146.                                 match=p.findall(link)
  147.                                 for a in match:
  148.                                                 f=urllib2.urlopen("http://mediaservices.myspace.com/services/rss.ashx?type=video&mediaID="+str(a))
  149.                                                 myspace=f.read()
  150.                                                 comp=re.compile('<media:content url="(.+?)"')
  151.                                                 for url in comp.findall(myspace):
  152.                                                                 addLink ('Play '+name,url,'')
  153.                 except:
  154.                         pass
  155.                 #YAHOO
  156.                 try:
  157.                                 yimg=re.compile('<param name="movie" value="http://d.yimg.com/static.video.yahoo.com/yep/YV_YEP.swf.+?id=(.+?)&amp;intl=us" />').findall(link)
  158.                                 for url in yimg:
  159.                                                 req = urllib2.Request('http://cosmos.bcst.yahoo.com/up/yep/process/getPlaylistFOP.php?node_id='+url)
  160.                                                 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')
  161.                                                 response = urllib2.urlopen(req).read()
  162.                                                 SERVER=re.compile('<STREAM APP="(.+?)"').findall(response)
  163.                                                 URL=re.compile('FULLPATH="(.+?)"').findall(response)
  164.                                                 FINAL=(SERVER[0]+URL[0]).replace('&amp;','&')
  165.                                                 addLink('Play '+name,FINAL,'')
  166.                 except:
  167.                         pass
  168.                 #MEGAVIDEO
  169.                 try:
  170.                                 mv=re.compile('<param name="movie" value="http://wwwstatic.megavideo.com/mv_player.swf.+?v=(.+)" />').findall(link)
  171.                                 mvlinks=mv[0][:8]
  172.                                 req = urllib2.Request("http://www.megavideo.com/xml/videolink.php?v="+mvlinks)
  173.                                 req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14')
  174.                                 req.add_header('Referer', 'http://www.megavideo.com/')
  175.                                 lemon = urllib2.urlopen(req);response=lemon.read();lemon.close()
  176.                                 errort = re.compile(' errortext="(.+?)"').findall(response)
  177.                                 if len(errort) > 0: addLink(errort[0],'http://novid.com','')
  178.                                 else:
  179.                                                 s = re.compile(' s="(.+?)"').findall(response)
  180.                                                 k1 = re.compile(' k1="(.+?)"').findall(response)
  181.                                                 k2 = re.compile(' k2="(.+?)"').findall(response)
  182.                                                 un = re.compile(' un="(.+?)"').findall(response)
  183.                                                 movielink = "http://www" + s[0] + ".megavideo.com/files/" + decrypt(un[0], k1[0], k2[0]) + "/"
  184.                                                 addLink('Play '+name, movielink+'?.flv','')
  185.                 except:
  186.                         pass
  187.  
  188. ####################################################################################################################
  189. # MegaVideo Routine
  190. ####################################################################################################################
  191.        
  192. #Python Video Decryption and resolving routines.
  193. #Courtesy of Voinage, Coolblaze.
  194. #Megavideo - Coolblaze # Part 1 put this below VIDEOLINKS function.
  195.  
  196. def ajoin(arr):
  197.     strtest = ''
  198.     for num in range(len(arr)):
  199.         strtest = strtest + str(arr[num])
  200.     return strtest
  201.  
  202. def asplit(mystring):
  203.     arr = []
  204.     for num in range(len(mystring)):
  205.         arr.append(mystring[num])
  206.     return arr
  207.        
  208. def decrypt(str1, key1, key2):
  209.  
  210.     __reg1 = []
  211.     __reg3 = 0
  212.     while (__reg3 < len(str1)):
  213.         __reg0 = str1[__reg3]
  214.         holder = __reg0
  215.         if (holder == "0"):
  216.             __reg1.append("0000")
  217.         else:
  218.             if (__reg0 == "1"):
  219.                 __reg1.append("0001")
  220.             else:
  221.                 if (__reg0 == "2"):
  222.                     __reg1.append("0010")
  223.                 else:
  224.                     if (__reg0 == "3"):
  225.                         __reg1.append("0011")
  226.                     else:
  227.                         if (__reg0 == "4"):
  228.                             __reg1.append("0100")
  229.                         else:
  230.                             if (__reg0 == "5"):
  231.                                 __reg1.append("0101")
  232.                             else:
  233.                                 if (__reg0 == "6"):
  234.                                     __reg1.append("0110")
  235.                                 else:
  236.                                     if (__reg0 == "7"):
  237.                                         __reg1.append("0111")
  238.                                     else:
  239.                                         if (__reg0 == "8"):
  240.                                             __reg1.append("1000")
  241.                                         else:
  242.                                             if (__reg0 == "9"):
  243.                                                 __reg1.append("1001")
  244.                                             else:
  245.                                                 if (__reg0 == "a"):
  246.                                                     __reg1.append("1010")
  247.                                                 else:
  248.                                                     if (__reg0 == "b"):
  249.                                                         __reg1.append("1011")
  250.                                                     else:
  251.                                                         if (__reg0 == "c"):
  252.                                                             __reg1.append("1100")
  253.                                                         else:
  254.                                                             if (__reg0 == "d"):
  255.                                                                 __reg1.append("1101")
  256.                                                             else:
  257.                                                                 if (__reg0 == "e"):
  258.                                                                     __reg1.append("1110")
  259.                                                                 else:
  260.                                                                     if (__reg0 == "f"):
  261.                                                                         __reg1.append("1111")
  262.  
  263.         __reg3 = __reg3 + 1
  264.  
  265.     mtstr = ajoin(__reg1)
  266.     __reg1 = asplit(mtstr)
  267.     __reg6 = []
  268.     __reg3 = 0
  269.     while (__reg3 < 384):
  270.    
  271.         key1 = (int(key1) * 11 + 77213) % 81371
  272.         key2 = (int(key2) * 17 + 92717) % 192811
  273.         __reg6.append((int(key1) + int(key2)) % 128)
  274.         __reg3 = __reg3 + 1
  275.    
  276.     __reg3 = 256
  277.     while (__reg3 >= 0):
  278.  
  279.         __reg5 = __reg6[__reg3]
  280.         __reg4 = __reg3 % 128
  281.         __reg8 = __reg1[__reg5]
  282.         __reg1[__reg5] = __reg1[__reg4]
  283.         __reg1[__reg4] = __reg8
  284.         __reg3 = __reg3 - 1
  285.    
  286.     __reg3 = 0
  287.     while (__reg3 < 128):
  288.    
  289.         __reg1[__reg3] = int(__reg1[__reg3]) ^ int(__reg6[__reg3 + 256]) & 1
  290.         __reg3 = __reg3 + 1
  291.  
  292.     __reg12 = ajoin(__reg1)
  293.     __reg7 = []
  294.     __reg3 = 0
  295.     while (__reg3 < len(__reg12)):
  296.  
  297.         __reg9 = __reg12[__reg3:__reg3 + 4]
  298.         __reg7.append(__reg9)
  299.         __reg3 = __reg3 + 4
  300.        
  301.    
  302.     __reg2 = []
  303.     __reg3 = 0
  304.     while (__reg3 < len(__reg7)):
  305.         __reg0 = __reg7[__reg3]
  306.         holder2 = __reg0
  307.    
  308.         if (holder2 == "0000"):
  309.             __reg2.append("0")
  310.         else:
  311.             if (__reg0 == "0001"):
  312.                 __reg2.append("1")
  313.             else:
  314.                 if (__reg0 == "0010"):
  315.                     __reg2.append("2")
  316.                 else:
  317.                     if (__reg0 == "0011"):
  318.                         __reg2.append("3")
  319.                     else:
  320.                         if (__reg0 == "0100"):
  321.                             __reg2.append("4")
  322.                         else:
  323.                             if (__reg0 == "0101"):
  324.                                 __reg2.append("5")
  325.                             else:
  326.                                 if (__reg0 == "0110"):
  327.                                     __reg2.append("6")
  328.                                 else:
  329.                                     if (__reg0 == "0111"):
  330.                                         __reg2.append("7")
  331.                                     else:
  332.                                         if (__reg0 == "1000"):
  333.                                             __reg2.append("8")
  334.                                         else:
  335.                                             if (__reg0 == "1001"):
  336.                                                 __reg2.append("9")
  337.                                             else:
  338.                                                 if (__reg0 == "1010"):
  339.                                                     __reg2.append("a")
  340.                                                 else:
  341.                                                     if (__reg0 == "1011"):
  342.                                                         __reg2.append("b")
  343.                                                     else:
  344.                                                         if (__reg0 == "1100"):
  345.                                                             __reg2.append("c")
  346.                                                         else:
  347.                                                             if (__reg0 == "1101"):
  348.                                                                 __reg2.append("d")
  349.                                                             else:
  350.                                                                 if (__reg0 == "1110"):
  351.                                                                     __reg2.append("e")
  352.                                                                 else:
  353.                                                                     if (__reg0 == "1111"):
  354.                                                                         __reg2.append("f")
  355.                                                                    
  356.         __reg3 = __reg3 + 1
  357.  
  358.     endstr = ajoin(__reg2)
  359.     return endstr
  360. def get_params():
  361.         param=[]
  362.         paramstring=sys.argv[2]
  363.         if len(paramstring)>=2:
  364.                 params=sys.argv[2]
  365.                 cleanedparams=params.replace('?','')
  366.                 if (params[len(params)-1]=='/'):
  367.                         params=params[0:len(params)-2]
  368.                 pairsofparams=cleanedparams.split('&')
  369.                 param={}
  370.                 for i in range(len(pairsofparams)):
  371.                         splitparams={}
  372.                         splitparams=pairsofparams[i].split('=')
  373.                         if (len(splitparams))==2:
  374.                                 param[splitparams[0]]=splitparams[1]
  375.                                
  376.         return param
  377. ########END OF PART 1
  378. #Part 2
  379. # To activate it just call Megavideo(url) - where url is your megavideo url.
  380. def Megavideo(url,info):
  381.     if len(url)<=35:
  382.         mega=re.sub('http://www.megavideo.com/v/','',url)
  383.     else:
  384.         mega=url[27:35]
  385.     req = urllib2.Request("http://www.megavideo.com/xml/videolink.php?v="+mega)
  386.     req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14')
  387.     req.add_header('Referer', 'http://www.megavideo.com/')
  388.     page = urllib2.urlopen(req);response=page.read();page.close()
  389.     errort = re.compile(' errortext="(.+?)"').findall(response)
  390.     if len(errort) > 0:
  391.         addLink(errort[0], '',4, '', '')
  392.     else:
  393.         s = re.compile(' s="(.+?)"').findall(response)
  394.         k1 = re.compile(' k1="(.+?)"').findall(response)
  395.         k2 = re.compile(' k2="(.+?)"').findall(response)
  396.         un = re.compile(' un="(.+?)"').findall(response)
  397.         movielink = "http://www" + s[0] + ".megavideo.com/files/" + decrypt(un[0], k1[0], k2[0]) + "/"
  398.         title = 'MEGAVIDEO '
  399.         addLink(name, movielink+'?.flv',4,'http://www.movie2k.com/img/mega.gif',info)
  400. ##
  401. #####END OF PART 2
  402.  
  403. def htmlencode(text):
  404.     """Use HTML entities to encode special characters in the given text."""
  405.     text = text.replace('?s=ea892d79ad897e243348fb5d08e1e86a&amp;', '?',)
  406.     return text
  407.  
  408.  
  409. def addLink(name,url,iconimage):
  410.         ok=True
  411.         liz=xbmcgui.ListItem(name, iconImage="DefaultVideo.png", thumbnailImage=iconimage)
  412.         liz.setInfo( type="Video", infoLabels={ "Title": name } )
  413.         ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=url,listitem=liz)
  414.         return ok
  415.  
  416.  
  417. def addDir(name,url,mode,iconimage):
  418.         u=sys.argv[0]+"?url="+urllib.quote_plus(url)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name)
  419.         ok=True
  420.         liz=xbmcgui.ListItem(name, iconImage="DefaultFolder.png", thumbnailImage=iconimage)
  421.         liz.setInfo( type="Video", infoLabels={ "Title": name } )
  422.         ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=True)
  423.         return ok
  424.        
  425.              
  426. params=get_params()
  427. url=None
  428. name=None
  429. mode=None
  430.  
  431. try:
  432.         url=urllib.unquote_plus(params["url"])
  433. except:
  434.         pass
  435. try:
  436.         name=urllib.unquote_plus(params["name"])
  437. except:
  438.         pass
  439. try:
  440.         mode=int(params["mode"])
  441. except:
  442.         pass
  443.  
  444. print "Mode: "+str(mode)
  445. print "URL: "+str(url)
  446. print "Name: "+str(name)
  447.  
  448. if mode==None or url==None or len(url)<1:
  449.         print ""
  450.         CATEGORIES()
  451.        
  452. elif mode==1:
  453.         print ""+url
  454.         PAGES(url)
  455.  
  456. elif mode==2:
  457.         print ""+url
  458.         INDEX(url)
  459.  
  460. elif mode==3:
  461.         print ""+url
  462.         PARTS(url)
  463.  
  464. elif mode==4:
  465.         print ""+url
  466.         VIDEOLINKS(url,name)
  467.  
  468.  
  469.  
  470.  
  471.  
  472. xbmcplugin.endOfDirectory(int(sys.argv[1]))
  473.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement