
# LyricsScreenlet Copyright (C) 2009 by Marcel Dancak <dancakm@gmail.com>

#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.


import urllib
import urllib2
import traceback

URL = 'http://webuser.byethost11.com/'
successful = []
unsuccessful = []
for n in range(1,1210):
	print n
	try:
		req = urllib2.Request(URL+"query.php", urllib.urlencode({'id': n}))
	
		response = urllib2.urlopen(req)
		lyrics = response.read()
		response.close()
		#print lyrics
		f = open("backup/%d.lrc" % n, "w")
		f.write(lyrics)
		f.close()
		successful.append(n)
	except Exception, ex:
		unsuccessful.append(n)
		#traceback.print_exc()
		print "%d - %s" % (n, str(ex))
		

print "Successful:"
print successful
print "-------------"
print "Unsuccessful:"
print unsuccessful
