<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[ToolBox]]></title><description><![CDATA[Information about various technology.]]></description><link>https://computergeek.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Mon, 21 Sep 2026 13:01:04 GMT</lastBuildDate><atom:link href="https://computergeek.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Accessing dictionary in python]]></title><description><![CDATA[Parameter Details

key = The desired key to lookup
value = The value to set or return


What exactly is a dictionary?

A real-life dictionary holds words and their meanings. As you can imagine, likewise, a Python dictionary holds key-value pairs. Als...]]></description><link>https://computergeek.hashnode.dev/accessing-dictionary-in-python</link><guid isPermaLink="true">https://computergeek.hashnode.dev/accessing-dictionary-in-python</guid><category><![CDATA[Python]]></category><category><![CDATA[Python 3]]></category><category><![CDATA[python beginner]]></category><category><![CDATA[python projects]]></category><category><![CDATA[Programming Blogs]]></category><dc:creator><![CDATA[COMPUTERGEEK]]></dc:creator><pubDate>Thu, 05 Aug 2021 12:33:51 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1628166164713/0QC9S5rAm.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>Parameter Details</strong></p>
<blockquote>
<p>key = The desired key to lookup</p>
<p>value = The value to set or return</p>
</blockquote>
<hr />
<p><strong>What exactly is a dictionary?</strong></p>
<blockquote>
<p>A real-life dictionary holds words and their meanings. As you can imagine, likewise, a Python dictionary holds key-value pairs. Also to be noted that they are Unordered and mutable.</p>
</blockquote>
<hr />
<p><strong>How to create one ?</strong></p>
<pre><code class="lang-python">mydict = {}                <span class="hljs-comment">#Empty dictionary</span>
mydict = {<span class="hljs-string">'key'</span> : <span class="hljs-string">'value'</span>} <span class="hljs-comment">#Initialized dictionary</span>
person = {<span class="hljs-string">'name'</span>:<span class="hljs-string">'xyz'</span>, <span class="hljs-string">'age'</span>:
</code></pre>
<p><strong>Built in Function for creating a dictionary: dict()</strong></p>
<pre><code class="lang-python">myperson = dict() <span class="hljs-comment">#empty dictionary</span>
myperson = dict(name=<span class="hljs-string">"xyz"</span>, age=<span class="hljs-number">23</span>) <span class="hljs-comment">#here we have given value to dict function</span>

<span class="hljs-comment"># while using dict function we dont need quotes or colons.</span>
</code></pre>
<p><strong>Modifying a dictionary</strong></p>
<pre><code class="lang-python">myperson = dict(name=<span class="hljs-string">"xyz"</span>, age=<span class="hljs-number">23</span>) <span class="hljs-comment">#creating a dict</span>
myperson[<span class="hljs-string">"email"</span>] = <span class="hljs-string">"xyz@gmail.com"</span> <span class="hljs-comment">#adding email as key and its value to dict</span>
</code></pre>
<p><strong>Adding list to a dictionary</strong></p>
<pre><code class="lang-python">myperson[<span class="hljs-string">'new_list'</span>] = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>] <span class="hljs-comment">#adding new_list as key and [1,2,3] as value</span>
</code></pre>
<p><strong>Adding Dictionary to a dictionary</strong></p>
<pre><code class="lang-python">myperson[<span class="hljs-string">'new_dict'</span>] = {<span class="hljs-string">'nested_dict'</span>: <span class="hljs-number">1</span>} <span class="hljs-comment">#new_dict is the key and {'nested_dict': 1} is the value</span>
</code></pre>
<p><strong>To delete an item, delete the key from the dictionary</strong></p>
<pre><code class="lang-python"><span class="hljs-keyword">del</span> myperson[<span class="hljs-string">'email'</span>] <span class="hljs-comment">#here key is deleted</span>
</code></pre>
<hr />
<p><strong>Iterating Over a Dictionary</strong></p>
<blockquote>
<p>Yes, we can iterate over dictionary. Such structures on which we can iterate are called ITERABLE and things which iterates, like 'i' in for loop, that 'i' is called ITERATOR(abstract explanation).</p>
</blockquote>
<pre><code class="lang-python">myperson = {<span class="hljs-string">'name'</span>:<span class="hljs-string">'xyz'</span>, <span class="hljs-string">'age'</span>:<span class="hljs-number">23</span>}

<span class="hljs-keyword">for</span> key <span class="hljs-keyword">in</span> myperson:
    print(key, myperson[key],sep=<span class="hljs-string">" : "</span>)

<span class="hljs-comment"># key is iterated , so key is iterator here</span>
</code></pre>
<p><strong>The items() method can be used to loop over both the key and value simultaneously</strong></p>
<pre><code class="lang-python">myperson = {<span class="hljs-string">'name'</span>:<span class="hljs-string">'xyz'</span>, <span class="hljs-string">'age'</span>:<span class="hljs-number">23</span>}

<span class="hljs-keyword">for</span> key,values <span class="hljs-keyword">in</span> myperson.items():
    print(key,values)
</code></pre>
<p><strong>While the values() method can be used to iterate over only the values</strong></p>
<pre><code class="lang-python">myperson = {<span class="hljs-string">'name'</span>:<span class="hljs-string">'xyz'</span>, <span class="hljs-string">'age'</span>:<span class="hljs-number">23</span>}

<span class="hljs-keyword">for</span> values <span class="hljs-keyword">in</span> myperson.values():
    print(values)
</code></pre>
<hr />
<blockquote>
<p><strong>PART 2 - SOON</strong></p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[Getting the Transcription of a Video From Youtube using google cloud platform.]]></title><description><![CDATA[So, the other day I was searching for python code that gives me a transcript of any video, I did what all we do I searched everywhere on Internet but was unfortunate. But we are programmers best thing we do is search more on the internet. finally, I ...]]></description><link>https://computergeek.hashnode.dev/getting-the-transcription-of-a-video-from-youtube-using-google-cloud-platform</link><guid isPermaLink="true">https://computergeek.hashnode.dev/getting-the-transcription-of-a-video-from-youtube-using-google-cloud-platform</guid><category><![CDATA[Python]]></category><category><![CDATA[APIs]]></category><category><![CDATA[Google]]></category><category><![CDATA[Programming Blogs]]></category><category><![CDATA[General Programming]]></category><dc:creator><![CDATA[COMPUTERGEEK]]></dc:creator><pubDate>Wed, 28 Jul 2021 13:59:58 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1627479831652/NFSdMx7Gw.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>So, the other day I was searching for python code that gives me a transcript of any video, I did what all we do I searched everywhere on Internet but was unfortunate. But we are programmers best thing we do is search more on the internet. finally, I got the code I wanted, all thanks to 
Pragnakalp Techlabs
. Although the code was a little different from my expectations I did some filters on it and made it to view the transcripts of the youtube video.
Be patient there are going to be few steps involved in our process !!</p>
<p>First, you have to enable the Youtube API from the Google Cloud Platform.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1627480062606/7uTEu-BEI.png" alt="youtub-data-Api-v3.png" /></p>
<p>Once you enabled this then do the following step</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1627480110479/UJ_NtKuOy.png" alt="Api-services.png" /></p>
<p>The credentials thing is used to Get the Youtube API for us.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1627480150953/tFxQHn8hF.jpeg" alt="3.jpg" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1627480163231/j37_3-oBs.jpeg" alt="4.jpg" /></p>
<p>Finally, we get our API key by following all these steps.
Now let us understand what is youtube VIDEO_ID</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1627480180423/faRF6WcY_.jpeg" alt="YOUTUBEID.jpg" /></p>
<p>The red part is the video_id of the Video that you want a transcript of.</p>
<p>Now all the steps are done let us look at the code.</p>
<pre><code>
<span class="hljs-comment"># pip install google-api-python-client</span>
<span class="hljs-comment"># pip install youtube_transcript_api</span>

<span class="hljs-keyword">from</span> apiclient.discovery <span class="hljs-keyword">import</span> build
<span class="hljs-keyword">from</span> youtube_transcript_api <span class="hljs-keyword">import</span> YouTubeTranscriptApi

api_key = <span class="hljs-string">"Secret Key"</span>  <span class="hljs-comment"># replace it with your API key</span>
video_id = str(input(<span class="hljs-string">"Enter the video id: "</span>))  <span class="hljs-comment"># replace it with your channel id</span>
youtube = build(<span class="hljs-string">'youtube'</span>, <span class="hljs-string">'v3'</span>,developerKey=api_key)

<span class="hljs-keyword">try</span>:
        responses = YouTubeTranscriptApi.get_transcript(
            video_id, languages=[<span class="hljs-string">'en'</span>])
        print(<span class="hljs-string">'\n'</span>+<span class="hljs-string">"Video: "</span>+<span class="hljs-string">"https://www.youtube.com/watch?v="</span> +
              str(video_id)+<span class="hljs-string">'\n'</span>+<span class="hljs-string">'\n'</span>+<span class="hljs-string">"Captions:"</span>)
        <span class="hljs-keyword">for</span> response <span class="hljs-keyword">in</span> responses:
            text = response[<span class="hljs-string">'text'</span>]
            print(text)
<span class="hljs-keyword">except</span> Exception <span class="hljs-keyword">as</span> e:
        print(e)
</code></pre><p>For more Tutorials, you can follow me on  <a target="_blank" href="https://medium.com/@computer_geek">Medium</a>  and  <a target="_blank" href="https://twitter.com/computer_geek77">Twitter</a> </p>
<p>To check the Original source code you can visit this website https://www.pragnakalp.com/automate-youtube-video-transcription-python/</p>
<p>Thanks for reading.
Hope you like it </p>
<p>Happy coding.</p>
]]></content:encoded></item></channel></rss>