Archive for the ‘bittorrent’ Category
Using Yahoo Pipes to create TV Torrent RSS Feeds
Yahoo Pipes is pretty cool allowing someone to create their own feed based on an aggregate of other feeds. It simplifies things immensely for creating nifty feeds of various things. More appropriately, Yahoo Pipes is ripe for abuse by those of us who want to create a feed of tv show torrent files we would like to download.
Where before I was filtering feeds locally, I choose to create a Pipe of the shows I want to download. This has the added benefit of letting you share the piped feed with other people so they can download the same torrents as you if they wish.
So how do we go about creating this feed? Here is a slideshow of how to do just that.
After it would be the same deal as before, but now we no longer need to do filtering.
So here is the new code:
#!/opt/local/bin/python2.5
import feedparser
import urllib2
DownloadPath = '/Users/abhi/Downloads/Feeds/'
DownloadLog = '/Users/abhi/.tvdownloads'
FeedUrl = 'http://pipes.yahoo.com/pipes/GBPk1Pm82xGRSPpPJxOy0Q/run?_render=rss'
def is_downloaded(link):
return link in open(DownloadLog, 'r+').read()
def write_log(link):
open(DownloadLog, 'a+').write('%s\n' % link)
def get_tvtorrents():
parser = feedparser.parse(FeedUrl)
for item in parser['items']:
if not is_downloaded(item['link']):
torrentfile = DownloadPath + item['title'].replace(' ', '_') + '.
torrent'
torrentdata = urllib2.urlopen(item['link']).read()
open(torrentfile, 'wb').write(torrentdata)
write_log(item['link'])
if __name__=='__main__':
get_tvtorrents()
TV Show Torrent Downloader Python Script
Democracy Player was being annoying and using up a lot of my computer’s resources including giving me the infamous MacBook whine. So I did what any script hacker would do and wrote my own script.
#!/usr/bin/env python
import feedparser
import urllib2
import pickle
import os
FILE_PATH = '/Users/abhi/Downloads/Feeds/'
DOWNLOADS_LOG = '/Users/abhi/bin/tvdownloads.txt'
FEED_URL = 'http://tvrss.net/feed/eztv/'
filters = ('Daily Show', 'Colbert', 'The Simpsons', 'Family Guy', 'Top Gear', 'Office',)
def main():
parser = feedparser.parse(FEED_URL)
try:
downloaded = pickle.load(open(DOWNLOADS_LOG))
except:
downloaded = []
for item in parser['items']:
for filter in filters:
torrent_link = item['enclosures'][0]['href']
filename = FILE_PATH + item['title'].replace(' ', '_') + '.torrent'
if filter in item['title']:
if not item['id'] in downloaded:
open(filename, 'wb').write(urllib2.urlopen(torrent_link).read())
downloaded.append(item['id'])
if os.uname()[0] == 'Darwin':
os.system("open " + filename)
pickle.dump(downloaded, open(DOWNLOADS_LOG, 'w'))
if __name__=='__main__':
main()
So what does this code do?
- file_path is where the torrent files are downloaded to.
- feed_url is the url of the torrent files containing rss feed.
- downloads_file is the txt file that contains the already downloaded files.
- filters is a tuple that contains part of the tv show that you want to download.
So make this a cron job and the feed is checked every n minutes/hours for new updates.
20 * * * * /Users/abhi/bin/tvtorrent.py > /dev/null