Example #1
0
 def __init__(self, mininovaId):
     self.data = get_data(mininovaId)
     if not self.data:
         return
     Torrent.__init__(self)
     ratio = self.data['share ratio'].split(',')
     self['seeder'] = -1
     self['leecher'] = -1
     if len(ratio) == 2:
         val = int_value(ratio[0].replace(',','').strip())
         if val:
             self['seeder'] = int(val)
         val = int_value(ratio[1].replace(',','').strip())
         if val:
             self['leecher'] = int(val)
     val = int_value(self.data['downloads'].replace(',','').strip())
     if val:
         self['downloaded'] = int(val)
     else:
         self['downloaded'] = -1
     published =  self.data['added on']
     published = published.split(' +')[0]
     self['published'] =  datetime.strptime(published, "%a, %d %b %Y %H:%M:%S")
Example #2
0
 def __init__(self):
     for key in self._string_keys:
         self[key] = self.data.get(key, u'')
     for key in self._dict_keys:
         self[key] = self.data.get(key, {})
     for key in self._list_keys:
         self[key] = self.data.get(key, [])
     for key in self._int_keys:
         value = self.data.get(key, -1)
         if not isinstance(value, int):
             value = int(int_value(value))
         self[key] = value
     self['infohash'] = self.data['torrent_info'].get('hash', '')
     self['size'] = self.data['torrent_info'].get('size', -1)
     self['announce'] = self.data['torrent_info'].get('announce', '')
     if 'files' in self.data['torrent_info']:
         self['files'] = len(self.data['torrent_info']['files'])
     else:
         self['files'] =  1