victorpimentel / TVShows

TVShows 2 is the easiest way to download your favorite TV shows automatically in you Mac.
http://tvshowsapp.com/
GNU General Public License v3.0
436 stars 105 forks source link

Fixed bug that causes some magnet links to fail opening #68

Closed rops closed 10 years ago

rops commented 10 years ago

Found the bug that was causing some magnet link to fail opening. URL escaping in TSTorrentFunctions.m downloadEpisode: ofShow: (line 102) should be done as:

[NSURL URLWithString:[url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]

instead of

[url stringByReplacingOccurencesOfString:@" " withString:@"%20"]

Replacing whitespaces with "%20" could result in a malformed string not accepted by URLWithString: (in which case the return value is nil and clearly openURL:nil ends up in doing nothing).

Thanks for all your work btw :)

victorpimentel commented 10 years ago

Hi Daniele, I'm trying to find an example where this fails, but I didn't find anything. Can you please send me such example? Thank you very much for your help!

rops commented 10 years ago

I can reproduce the bug on Mavericks using magnet links and trying to download any of the last episodes of The Big Bang Theory (7x11, 7x10,7x09..). This is the log entry related to that:

2013-12-16 01:13:17.225     INFO: [631 ~ Main App] Downloading magnet:?xt=urn:btih:29e6b4b40d76ae9250a9ca0321460700feed65d8&dn=The.Big.Bang.Theory.S07E09.720p.HDTV.X264-DIMENSION&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3.

2013-12-16 01:13:17.225     INFO: [631 ~ Main App] Attempting to download new episode: The Big Bang Theory S07E09

There is a discuss about the very same problem here: http://support.tvshowsapp.com/discussions/problems/2905-tvshows-not-downloading-only-attempting-no-success Hope it helped.

victorpimentel commented 10 years ago

Crap, the problem is in the database! We were storing magnets of up to 200 characters, and so we were cropping links like those. With the very bad luck that some urls were cropped making them illegal URIs.

I'm very sorry, we had to regenerate the database and the length of the fields differed. I reverted it back to a more sane 500 max length. From now on, the new magnets will be created properly, I'll try to repair the old links in the database the following days.

We will not need this change in the client (I don't remember why I escaped the spaces), because this change will make the last part of the magnet URLs illegible to a web client (they will probably work because the clients have some generic trackers).

Thank you very very much for your help!!