LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General > LinuxQuestions.org Member Success Stories
User Name
Password
LinuxQuestions.org Member Success Stories Just spent four hours configuring your favorite program? Just figured out a Linux problem that has been stumping you for months?
Post your Linux Success Stories here.

Notices


Reply
  Search this Thread
Old 06-24-2019, 09:46 PM   #1
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,701

Rep: Reputation: 5542Reputation: 5542Reputation: 5542Reputation: 5542Reputation: 5542Reputation: 5542Reputation: 5542Reputation: 5542Reputation: 5542Reputation: 5542Reputation: 5542
CLI app to get podcast feed URLs


I've been getting into podcasts recently, and I've noticed that, a) a lot of clients expect you to just give them the RSS feeds that you want to subscribe to, and b) those RSS feeds aren't always easy to find.

So I kludged up a small script to query for them.

Code:
#!/usr/bin/env bash

if [[ "$1" == "" ]]; then
  exit 1
fi

PODCAST=$(http "https://itunes.apple.com/search?media=podcast&term=$1" | jq -r '.results[].collectionName' | fzf --select-1 --exit-0)

if [[ "$PODCAST" == "" ]]; then
  exit
fi

echo "$PODCAST"
http "https://itunes.apple.com/search?media=podcast&term=$PODCAST" | jq -r '.results[0].feedUrl'
Name it "podfeed" and call it like this:

Code:
podfeed "You Must Remember"
That currently gives you a menu of two choices:
  • You Must Remember Manson
  • You Must Remember This

Narrow down the list by typing, or use the arrow keys to make a selection, and press ENTER.

Then you'll see:

Code:
You Must Remember Manson
http://feeds.megaphone.fm/PPY3689373157
Note that this uses a fairly modern pipeline, specifically:

I'll decline to link to the iTunes search API documentation, as all I did was look at what CPod does:

https://github.com/z-------------/CP...ch-podcasts.js

For more ideas on what you can do with FZF, see here:

How FZF and ripgrep improved my workflow
 
Old 06-25-2019, 07:50 AM   #2
individual
Member
 
Registered: Jul 2018
Posts: 315
Blog Entries: 1

Rep: Reputation: 233Reputation: 233Reputation: 233
That's pretty neat, Dugan. My only question is whether it would be better to store the result of the first search in a variable, that way you don't need to call the same URL again?
Something like this?
Code:
#!/usr/bin/env bash

data="$(<1.txt)"
feedNames="$(<<<"$data" jq '.results[].collectionName')"
<<<"$data" jq -r ".results[] | select(.collectionName == $(fzy <<< "$feedNames")) | .feedUrl"
EDIT: By the way, I use fzy, but it works just the same with fzf.
 
1 members found this post helpful.
Old 06-27-2022, 06:32 PM   #3
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,701

Original Poster
Rep: Reputation: 5542Reputation: 5542Reputation: 5542Reputation: 5542Reputation: 5542Reputation: 5542Reputation: 5542Reputation: 5542Reputation: 5542Reputation: 5542Reputation: 5542
I wrote another implementation using skim. This one will just give you a prompt and an autocomplete. It's slightly less responsive because it's sending a request to itunes with each keystroke.

pdfd script to make it work:
Code:
#!/usr/bin/env bash

if [[ "$1" == "" ]]; then
  exit 1
fi

http "https://itunes.apple.com/search?media=podcast&term=$1" | jq -r '.results[].collectionName'
The new podfeed script you actually run:
Code:
#!/usr/bin/env bash

PODCAST=$(sk --ansi -i -c 'pdfd "{}" &')

if [[ "$PODCAST" == "" ]]; then
  exit
fi

URL=$(http "https://itunes.apple.com/search?media=podcast&term=$PODCAST" | jq -r '.results[0].feedUrl')

echo "$URL" "$PODCAST"
And do you want to know what else I did? I wrote my own podcast aggregator, Podfeeds.

Last edited by dugan; 06-27-2022 at 09:08 PM.
 
Old 04-29-2026, 09:03 PM   #4
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,701

Original Poster
Rep: Reputation: 5542Reputation: 5542Reputation: 5542Reputation: 5542Reputation: 5542Reputation: 5542Reputation: 5542Reputation: 5542Reputation: 5542Reputation: 5542Reputation: 5542
I just set up a new Fedora 44 installation, and the Skim version didn't work! I don't know if it was a breaking change to Skim or what.

Anyway, I just made a slight change to the top version. It now formats its output in a way the way my podcast client wants:

Code:
#!/usr/bin/env bash

if [[ "$1" == "" ]]; then
	exit 1
fi

PODCAST=$(http "https://itunes.apple.com/search?media=podcast&term=$1" | jq -r '.results[].collectionName' | fzf --select-1 --exit-0)

if [[ "$PODCAST" == "" ]]; then
	exit
fi

URL=$(http "https://itunes.apple.com/search?media=podcast&term=$PODCAST" | jq -r '.results[0].feedUrl')

echo - "$URL" \# "$PODCAST"
(As we've seen, some people are better at BASH than me; fork as needed).

Last edited by dugan; 04-29-2026 at 11:00 PM.
 
Old 05-23-2026, 06:33 PM   #5
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,701

Original Poster
Rep: Reputation: 5542Reputation: 5542Reputation: 5542Reputation: 5542Reputation: 5542Reputation: 5542Reputation: 5542Reputation: 5542Reputation: 5542Reputation: 5542Reputation: 5542
When I saw https://junegunn.github.io/fzf/tips/...p-integration/ I knew it was the right way to go. I finally got around to rewriting these scripts that way.

The helper _podfeed_query script:

Code:
#!/usr/bin/env bash

if [[ "$PODFEED_JSON" == "" ]]; then
	echo Please set PODFEED_JSON
	exit 1
fi

if [[ ! -f "$PODFEED_JSON" ]]; then
	echo PODFEED_JSON file not found
	exit 2
fi

# See: https://performance-partners.apple.com/search-api
curl --silent \
	--get \
	--data-urlencode "media=podcast" \
	--data-urlencode "entity=podcast" \
	--data-urlencode "attribute=titleTerm" \
	--data-urlencode "term=$1" \
	https://itunes.apple.com/search >"$PODFEED_JSON"

cat "$PODFEED_JSON" | jq -r '.results[].collectionName' | sort | uniq
The podfeed script you actually run:

Code:
#!/usr/bin/env bash

# Based on this tutorial:
# https://junegunn.github.io/fzf/tips/ripgrep-integration/

PODFEED_JSON=$(mktemp)
export PODFEED_JSON

# I couldn't get the start: binding to work.
# Fedora 44. FZF 0.70.0.

_podfeed_query "$1" | fzf \
	--disabled \
	--ansi \
	--select-1 \
	--bind "change:reload:_podfeed_query {q}" \
	--bind "enter:become:cat $PODFEED_JSON | jq -r '.results[0] | (\"- \" + .feedUrl + \" # \" + .collectionName)'"

rm -rf "$PODFEED_JSON"
Note I've dropped the HTTPie dependency. It's also much more efficient. Doesn't really matter, but it is. Yes, the inefficiency that was pointed out earlier has been addressed.

This will be the last time I update this thread, as the scripts now have a home here:

https://github.com/duganchen/podfeeds/tree/main/scripts

Last edited by dugan; 05-24-2026 at 12:17 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Cli.Fyi – A Tool To Quickly Retrieve Information About eMails, IP Addresses, URLs And Lots More From The CLI Or Browser LXer Syndicated Linux News 0 03-15-2018 03:03 PM
Exporting Amarok podcast URLs LinuxD Linux - Desktop 2 12-07-2009 01:21 AM
Democracy-player? Alternative internet-TV/vidblog/video-podcast feed aggregators? silencestone Slackware 4 12-16-2007 06:55 PM
Looking for RSS & Atom Feed (News Feed)? suse2166 Linux - Software 2 11-16-2006 04:58 PM
how to check urls and stop internet urls in network gface Linux - Networking 5 03-24-2005 09:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General > LinuxQuestions.org Member Success Stories

All times are GMT -5. The time now is 06:34 PM.

Contact Us - Advertising Info - Rules - Privacy - Donations - Contributing Member - LQ Sitemap - "Weather apps tell you it'll rain. Wyndo tells you when to go."
Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions