def download(self, result_item):
"""
Downloads a ROM.
:param result_item: ResultItem object.
"""
self.current_url = result_item.download_url
location = os.path.join(PlatformBase().download_location, result_item.system_dir)
# Check if the ROM directory exists, if not, create it.
if not os.path.exists(location):
os.makedirs(location)
req = urllib2.Request(self.base_url)
req.add_header('Referer', 'https://www.emuparadise.me/')
self.current_url = self.get_download_url()
filename = urllib2.unquote(self.current_url.split('/')[-1])
target_file_name = os.path.join(location, filename)
urllib.urlretrieve(self.current_url, target_file_name)
# with open(target_file_name, 'wb') as code:
# total_length = f.headers.get('content-length')
# if not total_length:
# code.write(f.content)
# else:
# total_length = int(total_length)
# while True:
# data = f.read(total_length / 100)
# if not data:
# break
# code.write(data)
#
ex = Compression(location)
ex.extract(target_file_name)
评论列表
文章目录