Skip to content

Commit e6890da

Browse files
committed
When fetching the torrent files, we now separate the file name, quote it with urllib2 and join it with the rest of the URL to avoid getting errors due certain characters like braces
1 parent 832de6c commit e6890da

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

mt_scrapper.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@
88
DOWNLOAD_DIR = 'Downloads'
99

1010
def downloadFile(url, directory):
11-
file = urllib2.urlopen(url)
11+
print "Voy a descargar la url %s" % url
1212

1313
fileName = url[url.rfind('/')+1:len(url)]
14+
# To avoid errors due special characters in the filename,
15+
# we use urllib2 to quote it
16+
url = url[0:url.rfind('/')+1] + urllib2.quote(fileName)
17+
print "La URL tras el quote es %s" % url
1418
fileName = directory + '/' + fileName
1519

20+
file = urllib2.urlopen(url)
1621
localFile = open(fileName, 'w')
1722
localFile.write(file.read())
1823
localFile.close()

0 commit comments

Comments
 (0)