Guest User

Untitled

a guest
Oct 17th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.02 KB | None | 0 0
  1. def artistSearching():
  2.     loginAndSearch()
  3.     results = (doWork(request.form['artist']))
  4.     map1 = {'torrents_ep': 0,'torrents_compilation': 1, 'torrents_single': 2,'torrents_remix': 3,'torrents_mixtape': 4,'torrents_guest_appearance': 5, 'torrents_remixed_by': 6}
  5.     results.sort(key=lambda x: map1[x[1]])
  6.     #return "hi"
  7.     html = """<html><head>
  8.    <script language="JavaScript" type="text/javascript">
  9.    
  10.    function getsupport ( selectedtype )
  11.    {
  12.      document.supportform.supporttype.value = selectedtype ;
  13.      document.supportform.submit() ;
  14.    }
  15.    
  16.    </script>
  17.    </head>
  18.    <body>
  19. """
  20.     x=0
  21.     entry_length = len(results)-1
  22.     while x<=entry_length:
  23.         print x
  24.         if (x==0 or results[x][1] != results[x-1][1]): # EP, Album, Mixes, Complication  code is fine
  25.             html+="<b>%s</b><br>\n" % results[x][1]
  26.  
  27.  
  28.         if(x==0 or results[x][2] != results[x-1][2]): # If album changes
  29.             html+="&nbsp;&nbsp;&nbsp;Album - <b>%s</b><br>\n" % results[x][2]
  30.  
  31.         if(x==0 or results[x][4].decode("utf8") != results[x-1][4].decode("utf8")): # If relase changes
  32.             print "Release = %s" % results[x][4]
  33.             html+="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Release - <b>%s</b><br>\n" % (results[x][4])
  34.             html+="<table border='1'\n<tr>"
  35.             while True: # should go over all releses
  36.  
  37.                 html+="""<tr><td><FORM METHOD="POST" ACTION="add/">\n
  38.                <INPUT TYPE="submit" VALUE="%s">\n
  39.                <input type="hidden" name='url' value='%s'>\n
  40.                </FORM></td></tr>\n""" % (results[x][3][0],results[x][0])
  41.                 print "This is x: %s" % x
  42.                 if(x+1 >= entry_length):
  43.                     x+=1
  44.                     break
  45.  
  46.                 if results[x][4] != results[x+1][4]: # if release is going to change again
  47.                     x+=1
  48.                     break
  49.  
  50.  
  51.  
  52.                 x+=1
  53.  
  54.  
  55.  
  56.             html+="</tr></table>\n</body></html>"    
  57.    
  58.     return Markup(html)
Add Comment
Please, Sign In to add comment