add a noplaylist shortcut
- ID
a365db1- date
2023-07-06 21:15:23+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
62bfda2- message
add a noplaylist shortcut- changed files
2 files, 29 additions, 1 deletion
Changed files
text/README.md (1768) → text/README.md (2032)
diff --git a/text/README.md b/text/README.md
index 9d3c602..5fa06e8 100644
--- a/text/README.md
+++ b/text/README.md
@@ -15,6 +15,15 @@ These are utilities for manipulating streams of text; I consider them in a simil
</dd>
<dt>
+ <a href="https://github.com/alexwlchan/scripts/blob/main/text/noplaylist">
+ <code>noplaylist < [URL]</code>
+ </a>
+ </dt>
+ <dd>
+ removes the <code>list</code> query parameter from a YouTube URL; I use it with <code>youtube-dl</code>
+ </dd>
+
+ <dt>
<a href="https://github.com/alexwlchan/scripts/blob/main/text/randline">
<code>randline [NUMBER] < [PATH]</code>
</a>
@@ -43,7 +52,6 @@ These are utilities for manipulating streams of text; I consider them in a simil
<pre><code>echo -e '100 \n 201287 \n 3190817' | sumsizes</code></pre>
</dd>
-
<dt>
<a href="https://github.com/alexwlchan/scripts/blob/main/text/randline">
<code>tally < [PATH]</code>
text/noplaylist (0) → text/noplaylist (511)
diff --git a/text/noplaylist b/text/noplaylist
new file mode 100755
index 0000000..1d79930
--- /dev/null
+++ b/text/noplaylist
@@ -0,0 +1,20 @@
+#!/usr/bin/env python3
+"""
+This script receives a YouTube URL on stdin, and removes the `list`
+query parameter.
+
+I use this in conjunction with `furl` and `youtube-dl`. Sometimes
+I want to download a single video from YouTube, but youtube-dl tries
+to download an entire playlist. This lets me grab just the first video.
+"""
+
+import sys
+
+import hyperlink
+
+
+if __name__ == '__main__':
+ url = sys.stdin.read()
+ url = hyperlink.URL.from_text(url)
+ url = url.remove('list')
+ sys.stdout.write(str(url))