| | |
brain stroming ideas for program
![]() |
•
•
Join Date: May 2005
Posts: 215
Reputation:
Solved Threads: 16
I would like to write an application that would search a site like "minitorrents.com" and automatically download torrent files of tv shows I like. I am thinking urllib.py might be able to do something like this. I need to be able to use the search feature of "minitorrents.com", then recursivley follow a few levels into the sight, until my torrent file is found, then download it. Any ideas or suggestions would be appreciated.
In a perfect world exceptions would not be needed.
•
•
Join Date: May 2005
Posts: 215
Reputation:
Solved Threads: 16
I have found a sight that uses rss feeds. I can use the module feedparser.py to get most of the job done. Here is where I am stuck. I get a url that looks like this, using feedparser.py
http://isohunt.com/btDetails.php?ihq...ens&id=6071088
on this page(the link above) their is a link I click on called "download.torrent". Then that opens up the save dialog in my browser that allows me to download the torrent file. Is there a way to download this torrent file, aoutomatically(not using my web browser) using urllib2 or some other module?
http://isohunt.com/btDetails.php?ihq...ens&id=6071088
on this page(the link above) their is a link I click on called "download.torrent". Then that opens up the save dialog in my browser that allows me to download the torrent file. Is there a way to download this torrent file, aoutomatically(not using my web browser) using urllib2 or some other module?
In a perfect world exceptions would not be needed.
•
•
Join Date: May 2005
Posts: 215
Reputation:
Solved Threads: 16
I was overcomplicating it, this was all I needed
Python Syntax (Toggle Plain Text)
urllib.urlretrieve('http://isohunt.com/download.php?mode=bt&id=6071088', 'king.torrent')
In a perfect world exceptions would not be needed.
•
•
Join Date: May 2005
Posts: 215
Reputation:
Solved Threads: 16
•
•
•
•
Originally Posted by bumsfeld
This is pretty complex programming. You are leaving me in awe!
My programming skills are not that strong. I pretty much just know how to use the basic constructs: loops, if then statments, and the other basic stuff. Python does most of the work for me, there is a module built to do just about anything, you just need to string them together :-) In a perfect world exceptions would not be needed.
•
•
Join Date: May 2005
Posts: 215
Reputation:
Solved Threads: 16
Thank you for the compliment :-)
If I do have a skill, it is hacking out short useful scripts(nothing technically complex). I figure the best way to learn python is by coding stuff. So I will try and code just about anything that can be coded(at my level of expertise). I am always looking for ideas.
edit adde later//
that is why I like python so much. You can impliment an idea very fast, without a whole lot of programming experience. It is very satisfieing to have something work and be useful, after just a few hours of coding.
If I do have a skill, it is hacking out short useful scripts(nothing technically complex). I figure the best way to learn python is by coding stuff. So I will try and code just about anything that can be coded(at my level of expertise). I am always looking for ideas.
edit adde later//
that is why I like python so much. You can impliment an idea very fast, without a whole lot of programming experience. It is very satisfieing to have something work and be useful, after just a few hours of coding.
In a perfect world exceptions would not be needed.
•
•
Join Date: May 2005
Posts: 215
Reputation:
Solved Threads: 16
I am always so impressed at the ease of using python. It lets you make such useful stuff with so little code(or programming experience).
This program depends on the python module feedparser (available at feedparser.org), It uses rss feeds provided by isohunt. The idea is you just need to to set your televison shows in this variable. below is a sample variable
you need to set two parts, the first is the title. Make sure you include the full title, including works like: 'and', 'a', and 'the'. The second number is the file size of your avifiles. If you do not want to specify a target file size, set it to 0.
it seems you can only get current shows for about 5 to 6 days after they were released. So long as you run the script every 4 or so days you will not miss any new shows
to run it on linux, change to the directory you want your torrent files saved, then just run the script.
to run it on windows, just drag the file to the directory you want your torrents saved to and click on the icon.
here is the code
This program depends on the python module feedparser (available at feedparser.org), It uses rss feeds provided by isohunt. The idea is you just need to to set your televison shows in this variable. below is a sample variable
Python Syntax (Toggle Plain Text)
feeds = [ ('medium', 350), ('the king of queens', 175), ('invasion', 350), ('two and a half men', 175), ('er', 0), ('yes dear', 175), ('deadwood', 0) ]
you need to set two parts, the first is the title. Make sure you include the full title, including works like: 'and', 'a', and 'the'. The second number is the file size of your avifiles. If you do not want to specify a target file size, set it to 0.
it seems you can only get current shows for about 5 to 6 days after they were released. So long as you run the script every 4 or so days you will not miss any new shows
to run it on linux, change to the directory you want your torrent files saved, then just run the script.
to run it on windows, just drag the file to the directory you want your torrents saved to and click on the icon.
here is the code
Python Syntax (Toggle Plain Text)
#!/usr/bin/env python # # import os, feedparser, urllib # this is the url used to search isohunt, 'shanenin' is used as a place holder rss_url = 'http://isohunt.com/js/rss.php?ihq=shanenin&op=and&iht' generic_download_url = 'http://isohunt.com/download.php?mode=bt&id=shanenin' # fill this part with the names of shows you want to track, and # the prefered file size of your download. enter 0 for no preference # Entering 0 may retrun more bad torrents. feeds = [ ('medium', 0), ('the king of queens', 175), ('invasion', 350), ('two and a half men', 175), ('er', 0), ('yes dear', 175), ('deadwood', 0) ] # this function gets it parameter for the variable feed. Search is the first element of # each tuple in feeds def get_feed_obj(search): url = rss_url.replace('shanenin', search[0].replace(' ', '+')) feed_obj = feedparser.parse(url) return feed_obj # this function takes the summary, and parses out the file size in MBs # this is used for the parse_rss() def get_size(summary): size = summary.split('Size:')[1] size = float(size.split()[0]) return size # this function takes the link and parses out the torrent id, this is used for # the parse_rss() def get_id(v_link): id = v_link.split('id=')[1] return id # this function checks if a directory is already made, if not it makes it def mkdir(name): if os.path.isdir(name) == False: os.mkdir(name) # function either returns feed with '.' for spaces, or '_' def clean_feeds(feed, delimeter): cfeed = feed.replace(' ', delimeter).lower() return cfeed def main(): for i in feeds: direc = clean_feeds(i[0], '_') mkdir(direc) search_term = "%s."% clean_feeds(i[0], '.') size_parse = i[1] feed_obj = get_feed_obj(i) for i in range(len(feed_obj.entries)): title = feed_obj.entries[i].title.lower() id = get_id(feed_obj.entries[i].link) size = get_size(feed_obj.entries[i].summary) print_size = str(int(size)) modified = feed_obj.entries[i].modified if title.startswith(search_term): if size_parse == 0 or size >= size_parse - 4 and size <= size_parse +4: download_url = generic_download_url.replace('shanenin', id) saved_title = "%s/%s.%s.torrent" %(direc, title, print_size) urllib.urlretrieve(download_url, saved_title) main()
In a perfect world exceptions would not be needed.
![]() |
Similar Threads
- Gliven, I need an idea for a program... help anyone? (Pascal and Delphi)
Other Threads in the Python Forum
- Previous Thread: Text Encryption/Decryption with XOR (Python)
- Next Thread: Searching Text (Python)
| Thread Tools | Search this Thread |
abrupt accessdenied anti apache application approximation argv array beginner book builtin calculator change converter countpasswordentry curved dan08 dictionaries dictionary dynamic edit enter examples file float format function gui heads homework import inches input java keyboard lapse launcher library line lines linux list lists loop microphone mouse movingimageswithpygame mysqlquery newb number numbers numeric output parameters parsing path phonebook plugin port prime programming projects py2exe pygame pyopengl python random recursion redirect remote reverse scrolledtext session simple software sprite statictext statistics string strings syntax table terminal text textarea threading time tlapse trick tuple tutorial twoup ubuntu unicode unit urllib urllib2 variable wordgame wxpython






