Created
October 5, 2015 02:21
-
-
Save ssplatt/7fa02084231519b065ff to your computer and use it in GitHub Desktop.
add torrent to transmission from rss feed and sort into subdirectory based on file name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import feedparser, subprocess, urllib2, re, os, libtorrent | |
| out_dir_base = '' | |
| logfile = '' | |
| rss='' | |
| feed = feedparser.parse(rss) | |
| log = open( logfile, 'r+' ) | |
| log_cont = log.read() | |
| for item in feed['items']: | |
| if not item['link'] in log_cont: | |
| torr = urllib2.urlopen(item['link']).read() | |
| torr_dec = libtorrent.bdecode(torr) | |
| info = libtorrent.torrent_info(torr_dec) | |
| m = re.match( '([\w\d\(\)\.]+)\.([\d]{4}|[sS][0-9]{1,2}[eE][0-9]{1,2})', info.name() ) | |
| down_dir = os.path.join( out_dir_base, m.group(1).replace('.', ' ') ) | |
| if not os.path.exists(down_dir): | |
| os.makedirs(down_dir) | |
| subprocess.call( ['transmission-remote', 'localhost', '-a', item['link'], '-w', down_dir] ) | |
| log.write( item['link'] + '\n' ) | |
| log.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment