{"id":7846,"date":"2019-12-28T22:00:00","date_gmt":"2019-12-28T21:00:00","guid":{"rendered":"https:\/\/www.newstechnology.eu\/it\/?p=7846"},"modified":"2019-12-28T19:52:08","modified_gmt":"2019-12-28T18:52:08","slug":"convertire-video-youtube-in-mp3-con-python","status":"publish","type":"post","link":"https:\/\/www.newstechnology.eu\/it\/software\/open-source\/convertire-video-youtube-in-mp3-con-python.html","title":{"rendered":"Convertire Video Youtube in Mp3 con Python"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">I contenuti che si trovano online spesso sono disponibili senza copyright ed possiamo facilmente <strong>convertire un video Youtube in file mp3<\/strong> (rispetta sempre le regole copyright!).<\/p>\n\n\n\n<!--more-->\n\n\n\n<p class=\"wp-block-paragraph\">La conversione che in genere si vuole fare riguarda soprattutto musica e traccie audio di artisti famosi.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Attraverso <strong>librerie Python <\/strong>e con l&#8217;uso di Linux possiamo convertire con semplici comandi il <strong>video youtube in file Mp3<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-medium\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"300\" src=\"https:\/\/www.newstechnology.eu\/it\/wp-content\/uploads\/2019\/12\/youtube-to-mp3-300x300.png\" alt=\"Youtube to Mp3\" class=\"wp-image-7850\" srcset=\"https:\/\/www.newstechnology.eu\/it\/wp-content\/uploads\/2019\/12\/youtube-to-mp3-300x300.png 300w, https:\/\/www.newstechnology.eu\/it\/wp-content\/uploads\/2019\/12\/youtube-to-mp3-150x150.png 150w, https:\/\/www.newstechnology.eu\/it\/wp-content\/uploads\/2019\/12\/youtube-to-mp3-768x768.png 768w, https:\/\/www.newstechnology.eu\/it\/wp-content\/uploads\/2019\/12\/youtube-to-mp3.png 800w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">L&#8217;occorrente \u00e8 semplice:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Python 3<\/li><li>Linux<\/li><li>ffmpeg (apt install ffmpeg)<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Il tools che utilizzeremo \u00e8 <a href=\"https:\/\/pypi.org\/project\/yt2mp3\/\"><strong>yt2mp3<\/strong><\/a>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Installazione<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Installiamo python 3 con virtualenv:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>virtualenv -p \/usr\/bin\/python3 venv\nsource venv\/bin\/activate<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">A questo punto siamo entrati nella shell virtuale (cartella venv) nella quale possiamo installare il nostro tools.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip3 install yt2mp3<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Utilizzo yt2mp3<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Visualizziamo ora l&#8217;help del tools:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>yt2mp3 -h\nusage: yt2mp3 &#91;options]\n\noptional arguments:\n  -h, --help            show this help message and exit\n  --version             show the program version number and exit\n  -t TRACK &#91;TRACK ...], --track TRACK &#91;TRACK ...]\n                        specify the track name query\n  -a ARTIST &#91;ARTIST ...], --artist ARTIST &#91;ARTIST ...]\n                        specify the artist name query\n  -c, --collection      specify the album name query\n  -u URL, --url URL     specify the YouTube URL\/ID of the video to convert\n  -p PLAYLIST, --playlist PLAYLIST\n                        specify the YouTube URL\/ID of the playlist to convert\n  -r RESOLUTION, --resolution RESOLUTION\n                        specify the resolution for the cover-art image\n  -o, --overwrite       overwrite file if one exists in output directory\n  -v, --verbose         display a download progress bar\n  -q, --quiet           suppress command-line output\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Se come opzione non inseriamo nulla ci chieder\u00e0 il <em>nome della traccia<\/em> e dell&#8217;<em>artista<\/em> in questo modo (nell&#8217;esempio traccia big bang e artista Jovanotti):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>yt2mp3 \n Track: big bang\n Artist: Jovanotti\n&#x2714; Download Complete\n\u266c Converting to MP3\n&#x2714; Done\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Il nostro file Mp3 sar\u00e0 collocato nella cartella <em>~\/Downloads\/Music\/<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">L&#8217;installazione pu\u00f2 facilmente essere fatta in un contenitore docker.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Spero che il tutorial vi sia stato utile.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I contenuti che si trovano online spesso sono disponibili senza copyright ed possiamo facilmente convertire un video Youtube in file mp3 (rispetta sempre le regole copyright!).<\/p>\n","protected":false},"author":1,"featured_media":7850,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"wpai_meta_description":"","footnotes":""},"categories":[24,15,14],"tags":[1414,1415,529,1411,1410,1413,1127,1412,530,1409],"class_list":["post-7846","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-freeware","category-linux","category-open-source","tag-artista","tag-convertire-video","tag-mp3","tag-python","tag-python3","tag-traccia","tag-video","tag-virtualenv","tag-youtube","tag-yt2mp3"],"_links":{"self":[{"href":"https:\/\/www.newstechnology.eu\/it\/wp-json\/wp\/v2\/posts\/7846","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.newstechnology.eu\/it\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.newstechnology.eu\/it\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.newstechnology.eu\/it\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.newstechnology.eu\/it\/wp-json\/wp\/v2\/comments?post=7846"}],"version-history":[{"count":4,"href":"https:\/\/www.newstechnology.eu\/it\/wp-json\/wp\/v2\/posts\/7846\/revisions"}],"predecessor-version":[{"id":7851,"href":"https:\/\/www.newstechnology.eu\/it\/wp-json\/wp\/v2\/posts\/7846\/revisions\/7851"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.newstechnology.eu\/it\/wp-json\/wp\/v2\/media\/7850"}],"wp:attachment":[{"href":"https:\/\/www.newstechnology.eu\/it\/wp-json\/wp\/v2\/media?parent=7846"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.newstechnology.eu\/it\/wp-json\/wp\/v2\/categories?post=7846"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.newstechnology.eu\/it\/wp-json\/wp\/v2\/tags?post=7846"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}