{"id":3508,"date":"2019-09-10T07:13:20","date_gmt":"2019-09-10T05:13:20","guid":{"rendered":"https:\/\/pythonprogramming.altervista.org\/?p=3508"},"modified":"2019-09-10T07:13:20","modified_gmt":"2019-09-10T05:13:20","slug":"error-key-with-pytube","status":"publish","type":"post","link":"https:\/\/pythonprogramming.altervista.org\/error-key-with-pytube\/","title":{"rendered":"Error &#8216;Key&#8217; with Pytube"},"content":{"rendered":"<h2>What is pytube?<\/h2>\n<p>It is a module for Python that let you download a video with pytube.<\/p>\n<p>In this page I will try to take see how to fix some issues that sometimes occur with this module.<\/p>\n<h2>Updated errors: 10\/09\/2019<\/h2>\n<p>The latest error was a<\/p>\n<h1 class=\"gh-header-title\"><span class=\"js-issue-title\">KeyError: &#8216;title&#8217;<\/span><\/h1>\n<p>Searching how to fix the error I made this, it&#8217;s rough but it works.<\/p>\n<p>Go in the pytube dir, making this<\/p>\n<div style=\"width: 747px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-3508-1\" width=\"747\" height=\"420\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/04\/output1.mp4?_=1\" \/><a href=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/04\/output1.mp4\">https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/04\/output1.mp4<\/a><\/video><\/div>\n<p>Go in the directory site-packages of your Python installation (see the video if you do not know where it is) and go into the pytube folder. Open with an editor the streams.py file. Go to line 176, comment it:<\/p>\n<pre class=\"lang:default decode:true \">        #title = self.player_config_args['title']<\/pre>\n<p>Go to line 177 and make it like this<\/p>\n<pre class=\"lang:default decode:true \">        filename = safe_filename(\"title\")<\/pre>\n<p>Save it and then test it running this code (you will be asked to input the address of the youtube video (right click on the video to have it) &#8230; dowload only no copyighted things).<\/p>\n<pre class=\"lang:default decode:true \">from pytube import YouTube\r\nurl = input(\"Video url: &gt; \")\r\nyt = YouTube(url)\r\nstream = yt.streams.first()\r\nstream.download() # this will download in your current working Dir<\/pre>\n<p>It will work<\/p>\n<p>Updated: 10.9.2019<\/p>\n","protected":false},"excerpt":{"rendered":"error &#8216;key&#8217; with pytube module to download video from youtube with Python\n<a class=\"moretag\" href=\"https:\/\/pythonprogramming.altervista.org\/error-key-with-pytube\/\"> [...]<\/a>","protected":false},"author":1,"featured_media":1618,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[50,543],"tags":[],"class_list":["post-3508","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-video","category-youtube"],"avopt_banners_inside_post":true,"avopt_banners_on_page":true,"av_copy_from":"","av_sharing_message":"","av_sharing_allowed":false,"av_sharing_on":{"fb":[],"tw":[]},"av_allow_affiliate_banner":false,"av_allow_affiliate_multi_banner":false,"av_show_affiliation_buy_button":false,"av_post_rating":true,"av_have_post_rating_value":false,"av_is_artificial_intelligence_content":false,"_links":{"self":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/3508","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/comments?post=3508"}],"version-history":[{"count":1,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/3508\/revisions"}],"predecessor-version":[{"id":3509,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/3508\/revisions\/3509"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/media\/1618"}],"wp:attachment":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/media?parent=3508"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/categories?post=3508"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/tags?post=3508"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}