Changeset 6f7770
- Timestamp:
- 02/23/2012 12:49:54 AM (13 years ago)
- Branches:
- 2.0.x, develop, master
- Children:
- 8452b63
- Parents:
- 2b01ba
- git-author:
- Thomas Hipp <thomashipp@googlemail.com> (02/22/2012 05:44:00 PM)
- git-committer:
- Calum Lind <calumlind+deluge@gmail.com> (02/23/2012 12:49:54 AM)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
deluge/plugins/AutoAdd/deluge/plugins/autoadd/core.py
r2b01ba r6f7770 162 162 component.get("EventManager").emit(AutoaddOptionsChangedEvent()) 163 163 164 def load_torrent(self, filename ):164 def load_torrent(self, filename, magnet): 165 165 try: 166 166 log.debug("Attempting to open %s for add.", filename) 167 _file = open(filename, "rb") 167 if magnet == False: 168 _file = open(filename, "rb") 169 elif magnet == True: 170 _file = open(filename, "r") 168 171 filedump = _file.read() 169 172 if not filedump: … … 175 178 176 179 # Get the info to see if any exceptions are raised 177 lt.torrent_info(lt.bdecode(filedump)) 180 if magnet == False: 181 lt.torrent_info(lt.bdecode(filedump)) 178 182 179 183 return filedump … … 216 220 # Skip directories 217 221 continue 218 elif os.path.splitext(filename)[1] == ".torrent": 222 else: 223 ext = os.path.splitext(filename)[1] 224 if ext == ".torrent": 225 magnet = False 226 elif ext == ".magnet": 227 magnet = True 228 else: 229 continue 219 230 try: 220 filedump = self.load_torrent(filepath )231 filedump = self.load_torrent(filepath, magnet) 221 232 except (RuntimeError, Exception), e: 222 233 # If the torrent is invalid, we keep track of it so that we … … 238 249 239 250 # The torrent looks good, so lets add it to the session. 240 torrent_id = component.get("TorrentManager").add( 241 filedump=filedump, filename=filename, options=opts, 242 owner=watchdir.get("owner", "localclient") 243 ) 251 if magnet == False: 252 torrent_id = component.get("TorrentManager").add( 253 filedump=filedump, filename=filename, options=opts, 254 owner=watchdir.get("owner", "localclient") 255 ) 256 elif magnet == True: 257 torrent_id = component.get("TorrentManager").add( 258 magnet=filedump, options=opts, 259 owner=watchdir.get("owner", "localclient") 260 ) 244 261 # If the torrent added successfully, set the extra options. 245 262 if torrent_id: … … 255 272 else: 256 273 component.get("TorrentManager").queue_bottom(torrent_id) 274 else: 275 # torrent handle is invalid and so is the magnet link 276 if magnet == True: 277 log.debug("invalid magnet link") 278 os.rename(filepath, filepath + ".invalid") 279 continue 257 280 258 281 # Rename, copy or delete the torrent once added to deluge.
Note:
See TracChangeset
for help on using the changeset viewer.