Louis-Philippe Véronneau - scripthttps://veronneau.org/2018-02-17T00:00:00-05:00Downloading all the Critical Role podcasts in one batch2018-02-17T00:00:00-05:002018-02-17T00:00:00-05:00Louis-Philippe Véronneautag:veronneau.org,2018-02-17:/downloading-all-the-critical-role-podcasts-in-one-batch.html<p>I've been watching <a href="https://en.wikipedia.org/wiki/Critical_Role">Critical Role</a><sup><a href="#note1">1</a></sup> for a
while now and since I've started my master's degree I haven't had much time to
sit down and watch the show on YouTube as I used to do.</p>
<p>I thus started listening to the podcasts instead; that way, I can listen to …</p><p>I've been watching <a href="https://en.wikipedia.org/wiki/Critical_Role">Critical Role</a><sup><a href="#note1">1</a></sup> for a
while now and since I've started my master's degree I haven't had much time to
sit down and watch the show on YouTube as I used to do.</p>
<p>I thus started listening to the podcasts instead; that way, I can listen to the
show while I'm doing other productive tasks. Pretty quickly, I grew tired of
manually downloading every episode each time I finished the last one. To make
things worst, the podcast is hosted on PodBean and they won't let you download
episodes on a mobile device without their app. Grrr.</p>
<p>After the 10th time opening the terminal on my phone to download the podcast
using some <code>wget</code> magic I decided enough was enough: I was going to write a
dumb script to download them all in one batch.</p>
<p>I'm a little ashamed to say it took me more time than I had intended... The
PodBean website uses semi-randomized URLs, so I could not figure out a way to
guess the paths to the hosted audio files. I considered using <code>youtube-dl</code> to
get the DASH version of the show on YouTube, but Google has been heavily
throttling DASH streams recently. Not cool Google.</p>
<p>I then had the idea to use iTune's RSS feed to get the audio files. Surely they
would somehow be included there? Of course Apple doesn't give you a simple RSS
feed link on the iTunes podcast page, so I had to rummage around and eventually
found out this is the link you have to use:</p>
<div class="highlight"><pre><span></span><code>https://itunes.apple.com/lookup?id=1243705452&entity=podcast
</code></pre></div>
<p>Surprise surprise, from the json file this links points to, I found out the main
Critical Role podcast page <a href="http://criticalrolepodcast.geekandsundry.com/feed/">has a proper RSS feed</a>. To my defense, the RSS
button on the main podcast page brings you to some PodBean crap page.</p>
<p>Anyway, once you have the RSS feed, it's only a matter of using <code>grep</code> and <code>sed</code>
until you get what you want.</p>
<p>Around 20 minutes later, I had downloaded all the episodes, for a total of 22Gb!
Victory dance!</p>
<video width="70%" style="margin-left:15%" autoplay loop>
<source src="https://veronneau.org/media/blog/2018-02-17/victory-dance.mp4" type="video/mp4" />
Video clip loop of the Critical Role doing a victory dance.
</video>
<h2>Script</h2>
<p>Here's the bash script I wrote. You will need <code>recode</code> to run it, as the RSS
feed includes some HTML entities.</p>
<div class="highlight"><pre><span></span><code><span class="c1"># Get the whole RSS feed</span>
wget<span class="w"> </span>-qO<span class="w"> </span>/tmp/criticalrole.rss<span class="w"> </span>http://criticalrolepodcast.geekandsundry.com/feed/
<span class="c1"># Extract the URLS and the episode titles</span>
<span class="nv">mp3s</span><span class="o">=(</span><span class="w"> </span><span class="k">$(</span>grep<span class="w"> </span>-o<span class="w"> </span><span class="s2">"http.\+mp3"</span><span class="w"> </span>/tmp/criticalrole.rss<span class="k">)</span><span class="w"> </span><span class="o">)</span>
<span class="nv">titles</span><span class="o">=(</span><span class="w"> </span><span class="k">$(</span>tail<span class="w"> </span>-n<span class="w"> </span>+45<span class="w"> </span>/tmp/criticalrole.rss<span class="w"> </span><span class="p">|</span><span class="w"> </span>grep<span class="w"> </span>-o<span class="w"> </span><span class="s2">"<title>.\+</title>"</span><span class="w"> </span><span class="se">\</span>
<span class="w"> </span><span class="p">|</span><span class="w"> </span>sed<span class="w"> </span>-r<span class="w"> </span><span class="s1">'s@</?title>@@g; s@ @\\@g'</span><span class="w"> </span><span class="p">|</span><span class="w"> </span>recode<span class="w"> </span>html..utf8<span class="k">)</span><span class="w"> </span><span class="o">)</span>
<span class="c1"># Download all the episodes under their titles</span>
<span class="k">for</span><span class="w"> </span>i<span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="si">${</span><span class="p">!titles[*]</span><span class="si">}</span>
<span class="k">do</span>
<span class="w"> </span>wget<span class="w"> </span>-qO<span class="w"> </span><span class="s2">"</span><span class="k">$(</span>sed<span class="w"> </span>-e<span class="w"> </span><span class="s2">"s@\\\@\\ @g"</span><span class="w"> </span><span class="o"><<<</span><span class="w"> </span><span class="s2">"</span><span class="si">${</span><span class="nv">titles</span><span class="p">[</span><span class="nv">$i</span><span class="p">]</span><span class="si">}</span><span class="s2">"</span><span class="k">)</span><span class="s2">.mp3"</span><span class="w"> </span><span class="si">${</span><span class="nv">mp3s</span><span class="p">[</span><span class="nv">$i</span><span class="p">]</span><span class="si">}</span>
<span class="k">done</span>
</code></pre></div>
<hr>
<p style="font-size:95%;"><a name="note1">1</a> - For those of you not familiar
with Critical Role, it's web series where a group of voice actresses and actors
from LA play Dungeons & Dragons. It's so good even people like me who never
played D&D can enjoy it..</p>