Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Script to fuck with www.indiangilma.com

By: a guest on Jan 15th, 2011  |  syntax: Python  |  size: 2.23 KB  |  views: 1,356  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/usr/bin/python
  2. """ Script to fuck with www.indiangilma.com """
  3. from xml.dom import minidom
  4. import urllib2
  5. import getopt
  6. import sys
  7. import re
  8.  
  9.  
  10. class IG:
  11.    
  12.     def get_xml(self,source):
  13.         """ uses to get the xml source from website """
  14.         file_pointer = urllib2.urlopen(source)
  15.         return file_pointer
  16.  
  17.     def get_url(self,fp):
  18.         """ gets the url from the xml"""
  19.         try:
  20.             xmldoc = minidom.parse(fp)
  21.             src = xmldoc.getElementsByTagName('src')
  22.         except:
  23.             return 'invalid video key'
  24.         return src[0].firstChild.data
  25.  
  26.     def get_id(self,url):
  27.         """ Gets the video id from  the url
  28.        
  29.        Sample url:
  30.        http://www.indiangilma.com/video/1257/mumbai-juhu-beach-teen
  31.        """
  32.         l = url.split('/')
  33.         l.reverse()
  34.         try:
  35.             return l[1]
  36.         except IndexError:
  37.             print "Invalid url"
  38.             usage()
  39.  
  40. def usage():
  41.     print >>sys.stderr,'Usage: %s [-i video_id][-r video_id_range] [-u video_url] [-f out_file]' % sys.argv[0]
  42.     sys.exit(1)
  43.  
  44. if __name__ == '__main__':
  45.     if sys.argv[1:] == []:
  46.         usage()
  47.     try:
  48.         opts,args = getopt.getopt(sys.argv[1:],'u:i:r:f:')
  49.     except getopt.GetoptError:
  50.         usage()
  51.     video_id = []
  52.     out_file = None
  53.     obj = IG()
  54.     for o, a in opts:
  55.         if o == '-u':
  56.             match = re.search('^http://|^www.indiangilma.com',a)
  57.             if match == None:
  58.                 usage()
  59.             else:
  60.                 video_id.append(obj.get_id(a))
  61.         elif o == '-i':
  62.             video_id.append(a)
  63.         elif o == '-r':
  64.             try:
  65.                 video_id = range(1,int(a))
  66.             except:
  67.                 print "Invalid range"
  68.                 usage()
  69.         elif o == '-f':
  70.             out_file  = a
  71.  
  72.     if out_file:
  73.         outfp = open(out_file,'w')
  74.     for i in video_id:
  75.         source  = 'http://www.indiangilma.com/media/player/config.php?vkey='+str(i)
  76.         fp = obj.get_xml(source)
  77.         durl = obj.get_url(fp)
  78.         print durl
  79.         durl = durl+'\n'
  80.         if durl != "invalid video key\n" and out_file:
  81.             outfp.write(durl)
  82.     if out_file:
  83.         outfp.close()
clone this paste RAW Paste Data