# -*- coding: utf-8 -*- import re from hashlib import md5 from module.common.json_layer import json_loads from module.network.RequestFactory import getURL from module.plugins.Plugin import chunks from module.plugins.hoster.XFileSharingPro import XFileSharingPro def getInfo(urls): # DDLStorage API Documentation: # http://www.ddlstorage.com/cgi-bin/api_req.cgi?req_type=doc ids = dict() for url in urls: m = re.search(DdlstorageCom.__pattern__, url) ids[m.group('ID')] = url for chunk in chunks(ids.keys(), 5): for _ in xrange(5): api = getURL('http://www.ddlstorage.com/cgi-bin/api_req.cgi', post={'req_type': 'file_info_free', 'client_id': 53472, 'file_code': ','.join(chunk), 'sign': md5('file_info_free%d%s%s' % (53472, ','.join(chunk), '25JcpU2dPOKg8E2OEoRqMSRu068r0Cv3')).hexdigest()}) api = api.replace('
', '').replace('', '') api = json_loads(api) if 'error' not in api: break result = list() for el in api: if el['status'] == 'online': result.append((el['file_name'], int(el['file_size']), 2, ids[el['file_code']])) else: result.append((ids[el['file_code']], 0, 1, ids[el['file_code']])) yield result class DdlstorageCom(XFileSharingPro): __name__ = "DdlstorageCom" __type__ = "hoster" __version__ = "1.01" __pattern__ = r'http://(?:www\.)?ddlstorage.com/(?P
]*>(?P[^)]+)\)
', '').replace('', '') self.logDebug('API Data: ' + self.api_data) self.api_data = json_loads(self.api_data)[0] if self.api_data['status'] == 'offline': self.offline() if 'file_name' in self.api_data: self.pyfile.name = self.api_data['file_name'] if 'file_size' in self.api_data: self.pyfile.size = self.api_data['size'] = self.api_data['file_size'] if 'file_md5_base64' in self.api_data: self.api_data['md5_ddlstorage'] = self.api_data['file_md5_base64']