{"id":10,"date":"2005-02-13T13:59:02","date_gmt":"2005-02-13T12:59:02","guid":{"rendered":""},"modified":"2005-10-24T21:43:39","modified_gmt":"2005-10-24T20:43:39","slug":"bashpodder-and-bittorrent","status":"publish","type":"post","link":"http:\/\/www.hlynes.com\/?p=10","title":{"rendered":"Bashpodder and BitTorrent"},"content":{"rendered":"<p><a href=\"http:\/\/linc.homeunix.org:8080\/scripts\/bashpodder\/\" target=\"_self\">Bashpodder<\/a>, in case you are not already familiar with it, is a command line tool for downloading <a href=\"http:\/\/en.wikipedia.org\/wiki\/Podcasting\" target=\"_self\">podcasts<\/a>.<br \/>\nI like it because it&#39;s unintrusive and can be run from a cron job.<br \/>\nWhich means when I get home in the evening I can just check today&#39;s<br \/>\ndownload directory and see what cool stuff I have to listen to. <\/p>\n<p><!--more--><br \/>I did some cleaning of the scrip on saturday afternoon to make it deal<br \/>\nwith disconnection in a more sane manner, and also to take advantage of<br \/>\nwget&#39;s ability to recomence a download that has already started. This<br \/>\nmeans that bashpodder should be a bit less of bandwidth whore in the<br \/>\nfuture.<\/p>\n<p>I subscribed to the RSS feed of <a href=\"www.evilgeniuschronicles.org\" target=\"_self\">evilgeniuschronicles<\/a>.<br \/>\nAll was well until I looked in my download directory to see lots of<br \/>\n*.mp3.torrent files. Bummer.&#160; Drunk on success I thought &quot;I shall<br \/>\nnow go forth and add bittorrent support to bashpodder&quot;. BitTorrent is<br \/>\nwriiten in python so I thought there was probably a good chance to get<br \/>\nwhere I wanted to go since I already know python. There is even a<br \/>\ncommand-line script called btdownloadheadles.py. However like most<br \/>\nbittorrent clients this stays open until it&#39;s explicitly killed. This<br \/>\nwasn&#39;t the behaviour I was looking for but I figured it wouldn&#39;t take<br \/>\ntoo much tweaking to get it to exit on success or failure. Six hours<br \/>\nlater at four in the morning I finally gave up and went to bed.<br \/>\nThrowing sys.exit(0) anywhere in the code just disn&#39;t seem to work.<\/p>\n<p>After a good sleep it took me about ten minutes to work out what had<br \/>\nbeen outfoxing me for hours. The bittorrent code treats a sys.exit(0)<br \/>\nas an error state. So you end up in the generic error function. By<br \/>\nadding a sys.exit(1) into the error function I could finally get the<br \/>\ndamn thing to exit. I tidied it up to add some checks in the error<br \/>\nfunction so that it calls sys.exit(0) is it got there by receiving<br \/>\nsys.exit(0) else it exits with a non-zero error code.<\/p>\n<p>Of course now that I I&#39;ve got working code the egr feed has gone down so I can&#39;t test it. It&#39;ll just have to wait till tommorow.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Bashpodder, in case you are not already familiar with it, is a command line tool for downloading podcasts. I like it because it&#39;s unintrusive and can be run from a cron job. Which means when I get home in the evening I can just check today&#39;s download directory and see what cool stuff I have &hellip; <a href=\"http:\/\/www.hlynes.com\/?p=10\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Bashpodder and BitTorrent<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-10","post","type-post","status-publish","format-standard","hentry","category-bashpodder"],"_links":{"self":[{"href":"http:\/\/www.hlynes.com\/index.php?rest_route=\/wp\/v2\/posts\/10"}],"collection":[{"href":"http:\/\/www.hlynes.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.hlynes.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.hlynes.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.hlynes.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10"}],"version-history":[{"count":0,"href":"http:\/\/www.hlynes.com\/index.php?rest_route=\/wp\/v2\/posts\/10\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.hlynes.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.hlynes.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.hlynes.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}