umputun / feed-master

Pulls multiple podcast feeds (RSS) and republishes as a common feed, properly sorted and podcast-client friendly.
https://feed-master.umputun.dev
MIT License
118 stars 26 forks source link

support yt hashtags #102

Open umputun opened 1 year ago

umputun commented 1 year ago

I don't think youtube provides rss for hashtags, but having such sources will be very useful. It can probably be extracted from hashtag page (looks like it embeds all the relevant data in "responseContext as a json)

rantanevich commented 1 year ago

I could find only several ways to extract video hashtags:

  1. Make GET request to https://www.youtube.com/watch?v={VideoID} and extract hashtags using RegExp (e.g. "keywords":\[(.+?)\],).

  2. Make the following request and get JSON response with hashtags

❯ VIDEO_ID=kFRdoYfZYUY

❯ resp=$(curl \
  'https://www.youtube.com/youtubei/v1/player?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8' \
  -s \
  -X POST \
  -H 'Content-Type: application/json' \
  -d @- <<EOF
  {
    "videoId": "$VIDEO_ID",
    "context": {
      "client": {
        "clientName": "IOS",
        "clientVersion": "17.33.2"
      }
    }
  }
EOF
)

❯ echo -E "$resp" | jq -r .videoDetails.keywords
[
  "Hania Rani",
  "Live from Studio S2",
  "Piano",
  "Live",
  "Warsaw",
  "Poland",
  "Piano Day"
]

But here there's pinch of magic. key param is INNERTUBE_API_KEY which can be changed anytime by Google.

umputun commented 1 year ago

This is somewhat opposite to what we need if I understood the idea correctly. This snippet seems to retrieve tags for a given video, but what we are looking for something to get the list of video ids (in some form) for a given tag

rantanevich commented 1 year ago

My bad. Now I understand the problem :)