Exemplo n.º 1
0
 def delrelease(self, torrent) :
     
     if not isTorrentFile(torrent) :
         return
     
     # search for basepath
     res = self.execute("SELECT `basepath` FROM `torrent` WHERE file = '%s' LIMIT 1" %(self.dbescape(torrent)))
     
     if res.num_rows() == 0 :
         # no torrent with that name exists, return.
         return 
     
     bp = int(res.fetch_row()[0][0])
     
     # delete the torrentfile
     self.dbh.query("DELETE FROM `torrent` WHERE file = '%s' LIMIT 1" %(self.dbescape(torrent)))
     
     # find torrents that is connected to the same basepath.
     res = self.execute("SELECT id FROM `torrent` WHERE basepath = %d LIMIT 1" %(bp))
     
     if res.num_rows() == 0 :
         # no torrents are connected to the basepath. delete it.
         self.dbh.query("DELETE FROM `basepath` WHERE id = %d LIMIT 1" %(bp))
         
     return 1
Exemplo n.º 2
0
 def addrelease(self, torrent) :
        
     if not isTorrentFile(torrent) :
         print "Error: %s is not a torrentfile" %(torrent)
         return
     
     try :
         base = bendecode(torrent)
         base = base['info']['name']
     except (IOError, BTFailure, KeyError), e:
         print "Error: " + e
         return
Exemplo n.º 3
0
#!/usr/bin/python2.5

import sys
import torrent

if torrent.isTorrentFile(sys.argv[1]) :
     print torrent.getBasepath(sys.argv[1])