{"id":110,"date":"2013-01-25T16:44:17","date_gmt":"2013-01-25T16:44:17","guid":{"rendered":"http:\/\/timbertops.co.uk\/blog\/?p=110"},"modified":"2013-01-25T16:44:17","modified_gmt":"2013-01-25T16:44:17","slug":"my-improved-youtube2mp3-converter-script","status":"publish","type":"post","link":"https:\/\/timbertops.co.uk\/index.php\/2013\/01\/25\/my-improved-youtube2mp3-converter-script\/","title":{"rendered":"My improved youtube2mp3 converter script"},"content":{"rendered":"<p>A while ago I found this article <a title=\"http:\/\/jeffreyv.hubpages.com\/hub\/Youtube-to-MP3-on-Ubuntu-Linux\" href=\"http:\/\/jeffreyv.hubpages.com\/hub\/Youtube-to-MP3-on-Ubuntu-Linux\" target=\"_blank\">http:\/\/jeffreyv.hubpages.com\/hub\/Youtube-to-MP3-on-Ubuntu-Linux<\/a> it did exactly what it wanted at the time but me been lazy like I am decided it was time to upgrade it a bit mainly so I just need to supply it with the location URL and it names the file itself. cue investigation into youtube-dl (which is awesome) after finding that it can return the video&#8217;s title I fairly quickly got the rest sorted so here it is:<!--more--><\/p>\n<p><code lang=\"bash[lines]\">#!\/bin\/bash<br \/>\nif [ \"$2\" = \"\" ]<br \/>\nthen<br \/>\n  name=$(youtube-dl -s --get-title \"$1\")<br \/>\n  name2=$(echo ${name} | sed -e s\/\"'\"\/\"\"\/g  -e 's\/ \/_\/g')<br \/>\n  echo \"No output file defined saving mp3 as:\"<br \/>\n  echo  \"\/var\/www\/\"${name2}\".mp3\"<br \/>\n  Output=\"\/var\/www\/\"${name2}\".mp3\"<br \/>\nelse<br \/>\n  echo \"Output file detected saving mp3 as:\"<br \/>\n  echo \"${2}\"<br \/>\n  Output=\"${2}\"<br \/>\nfi<br \/>\nx=~\/.youtube-dl-$RANDOM-$RANDOM.flv<br \/>\nyoutube-dl --output=$x --format=18 \"$1\"<\/p>\n<p>ffmpeg -i $x -acodec libmp3lame -ac 2 -ab 128k -vn -y \"${Output}\"<br \/>\nrm $x<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A while ago I found this article http:\/\/jeffreyv.hubpages.com\/hub\/Youtube-to-MP3-on-Ubuntu-Linux it did exactly what it wanted at the time but me been lazy like I am decided it was time to upgrade it a bit mainly so I just need to supply it with the location URL and it names the file itself. cue investigation into youtube-dl &hellip; <a href=\"https:\/\/timbertops.co.uk\/index.php\/2013\/01\/25\/my-improved-youtube2mp3-converter-script\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;My improved youtube2mp3 converter script&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":114,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[50,12,24],"tags":[43,51,29,49,25,52],"class_list":["post-110","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bash-programming","category-programming","category-ubuntu","tag-bash","tag-download","tag-linux","tag-programming-2","tag-ubuntu-2","tag-youtube"],"_links":{"self":[{"href":"https:\/\/timbertops.co.uk\/index.php\/wp-json\/wp\/v2\/posts\/110","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/timbertops.co.uk\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/timbertops.co.uk\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/timbertops.co.uk\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/timbertops.co.uk\/index.php\/wp-json\/wp\/v2\/comments?post=110"}],"version-history":[{"count":4,"href":"https:\/\/timbertops.co.uk\/index.php\/wp-json\/wp\/v2\/posts\/110\/revisions"}],"predecessor-version":[{"id":115,"href":"https:\/\/timbertops.co.uk\/index.php\/wp-json\/wp\/v2\/posts\/110\/revisions\/115"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/timbertops.co.uk\/index.php\/wp-json\/wp\/v2\/media\/114"}],"wp:attachment":[{"href":"https:\/\/timbertops.co.uk\/index.php\/wp-json\/wp\/v2\/media?parent=110"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/timbertops.co.uk\/index.php\/wp-json\/wp\/v2\/categories?post=110"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/timbertops.co.uk\/index.php\/wp-json\/wp\/v2\/tags?post=110"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}