Advertisement
Guest User

sansat

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