Skip to content

What's on NPR? Shortcut #199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
extratone opened this issue May 16, 2022 · 1 comment
Open

What's on NPR? Shortcut #199

extratone opened this issue May 16, 2022 · 1 comment
Labels
documentation Improvements or additions to documentation shortcut A Siri Shortcut! Built either by myself or another community member.

Comments

@extratone
Copy link
Owner

extratone commented May 16, 2022

Social


Retrieve live NPR program information with Siri Shortcuts

What's on NPR? Banner

For more information, please see my blog post about this shortcut.

Creating a Shortcut for Your NPR Station

All I really needed to customize Jack Wellborn's original shortcut was my NPR station's "UCSID,"which, for reference, is 5387648fe1c8335046a1d4b4. Upon installation of my What's on NPR? shortcut, you'll be prompted to specify this. Unfortunately, retrieving it via NPR's API requires special authorization, for some reason, but - since we're retrieving data from an NPR station's playback widget already configured to use the API - it's actually as easy as opening your browser's "Dev Tools" or showing on your given station's homepage. If you're unfamiliar, here's a handy guide to doing so on some popular desktop web browsers.

Web Inspector

Honestly, though, if you're already on your iOS/iPadOS device and you're willing to install a single, free Safari Extension, I believe you'll find Web Inspector to be the single, simplest method of retrieving your station's UCSID.

Finding UCSID-Web Inspector

Finding your station's UCSID with Web Inspector

  1. Navigate to your station's homepage (ex. kbia.org.)
  2. Start playback of the live stream you'd like to query (may or may not be necessary, depending.)
  3. Open Web Inspector via the Safari Extensions Menu.
  4. In the DOM tab, use the search icon to filter for ucsid.
  5. Your station's UCSID is the value for the data-stream-ucsid field.

Depending on how modern your station's website is (I think - I'm supposing, here,) you may or may not find this field. For reference, here is the HTML source of KBIA's webpage from which I drew in its entirety. If you're having trouble, please feel free to contact me however you wish, ideally with your preferred station's identifier/web url.

Broadcasts

"Integration" with the Broadcasts app

Broadcasts is a very popular and highly-praised universal Apple application for internet radio streaming. By default, my What's on NPR? shortcut includes an action to begin streaming a station in Broadcasts, but it requires further configuration.

Broadcasts App Integration

In all likelihood, a search of the Broadcasts Directory for your station's four-letter identifier should yield results. Once you've added your station to your library in Broadcasts, hold its icon (or ^ Tap) to present the context menu (shown in the screenshots embedded above) and select Edit. The exact value for the Name field in configuration menu that results must be supplied as the answer to the second configuration step of my What's on NPR? shortcut. If you do not wish to use Broadcasts, you need only delete or replace its single action in the shortcut's default configuration.

If you've followed along this far, you now have both values you're prompted for at installation of said shortcut, by default: your station's ucsid and its name in the Broadcasts app. You need only continue if you'd prefer to add options for Apple Music and/or VLC.

Finding an NPR Station's Apple Music URL

"Integration" with Apple Music

If you'd like to have a menu option to begin streaming your NPR station in Apple Music, begin by searching within the app for your station's identifier (as shown in the screenshot embedded above.) Use the triple-dot menu's Share Station option to copy its Apple Music URL. (WBEZ's, for example, is https://music.apple.com/us/station/npr-news-wbez-chicago/ra.872998937.) Replace or append to the Broadcasts option with a menu option pointing to an Open URLs action containing the resulting URL. (Refer to my What's on KBIA? shortcut to see this implemented.)

VLC

"Integration" with VLC media player

The VLC media player iOS app does not yet have its own Siri Shortcuts actions, but it does have a handy URL scheme which allows one to stream or download the contents of any raw media URL. Using Web Inspector as described above, I was able to find the raw stream URL for KBIA (https://playerservices.streamtheworld.com/api/livestream-redirect/KBIAFM.mp3) quite quickly in the Resources tab whilst streaming live.

Finding Raw Stream URL-Web Inspector

To add an option to my shortcut to open the stream in vlc, I would add the following value in an Open URLs action:

vlc-x-callback://x-callback-url/stream?url=https://playerservices.streamtheworld.com/api/livestream-redirect/KBIAFM.mp3
@extratone extratone changed the title # What's on KBIA? Shortcut What's on KBIA? Shortcut May 16, 2022
@extratone extratone added documentation Improvements or additions to documentation shortcut A Siri Shortcut! Built either by myself or another community member. labels May 16, 2022
@extratone extratone changed the title What's on KBIA? Shortcut What's on NPR? Shortcut Jun 5, 2022
@extratone
Copy link
Owner Author

KBIA Sample Data

{
  "status" : true,
  "nextUp" : [
    {
      "widget_config" : {
        "customized" : false,
        "custom_fields" : false,
        "episode_notes" : false,
        "host_allow" : false,
        "host_display" : false,
        "album_art" : false,
        "catalog_number" : false,
        "label" : false
      },
      "conflicts" : [
        "60bb015bc919e734e2b1c059"
      ],
      "_id" : "60bb015bc919e734e2b1c059",
      "start_time" : "16:00",
      "program_id" : "53876499e1c8335046a1d4cb",
      "start_utc" : "Sun Jun 05 2022 16:00:00 GMT-0400 (EDT)",
      "date" : "2022-06-05",
      "day" : "Sun",
      "conflict_edited" : 1444836534094,
      "fullend" : "2022-06-05 17:00",
      "end_time" : "17:00",
      "program" : {
        "hosts" : [
          {
            "name" : ""
          }
        ],
        "station_id" : "station_kbia_58",
        "program_format" : "News/Information",
        "program_link" : "http://www.npr.org/templates/rundowns/rundown.php?prgId=2",
        "parentID" : "517059399de8e95a460001ea",
        "program_id" : "53876499e1c8335046a1d4cb",
        "program_desc" : "An hour of breaking news mixed with compelling analysis, insightful commentaries, interviews, and special - sometimes quirky - features.",
        "ucs" : "5387648fe1c8335046a1d4b4",
        "national_program_id" : "5",
        "isParent" : false,
        "facebook" : "",
        "name" : "All Things Considered",
        "twitter" : ""
      },
      "end_utc" : "Sun Jun 05 2022 17:00:00 GMT-0400 (EDT)",
      "event_id" : "5387655079e9edc965cb75d8",
      "fullstart" : "2022-06-05 16:00"
    }
  ],
  "onNow" : {
    "widget_config" : {
      "customized" : false,
      "custom_fields" : false,
      "episode_notes" : false,
      "host_allow" : false,
      "host_display" : false,
      "album_art" : false,
      "catalog_number" : false,
      "label" : false
    },
    "_id" : "60bb015bc919e734e2b1c067",
    "start_time" : "15:00",
    "program_id" : "5636b8acad4228ea612923ce",
    "start_utc" : "2022-06-05T19:00:00.000Z",
    "date" : "2022-06-05",
    "day" : "Sun",
    "conflict_edited" : 1467839241304,
    "end_time" : "16:00",
    "program" : {
      "hosts" : [

      ],
      "station_id" : "",
      "program_format" : "News/Information",
      "program_link" : "",
      "parentID" : null,
      "program_id" : "5636b8acad4228ea612923ce",
      "program_desc" : "",
      "ucs" : "5387648fe1c8335046a1d4b4",
      "national_program_id" : "",
      "isParent" : false,
      "facebook" : "",
      "name" : "Reveal",
      "twitter" : ""
    },
    "end_utc" : "2022-06-05T20:00:00.000Z",
    "event_id" : "577d7309fd377abc5a585655"
  },
  "display_buy" : true,
  "affiliate" : {
    "amazon" : "kbiaorg-20",
    "itunes" : "10lJXC",
    "arkiv" : "kbia"
  },
  "settings" : {
    "times" : false
  },
  "ucs" : {
    "station" : "station_kbia_58",
    "itunes_affiliate_id" : "10lJXC",
    "_zoneInfo" : {
      "id" : "US_Central",
      "offset" : -6
    },
    "_id" : "5387648fe1c8335046a1d4b4",
    "amazon_affiliate_id" : "kbiaorg-20",
    "enable_sx_reporting" : true,
    "websitelink" : "http://www.kbia.org",
    "arkiv_affiliate_id" : "kbia",
    "ignores_dst" : false,
    "parent_station_id" : "0",
    "fullname" : "KBIA",
    "timezone" : "CST",
    "legacy" : "58",
    "name" : "kbia"
  }
}

extratone added a commit that referenced this issue Jun 5, 2022
extratone added a commit that referenced this issue Jun 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation shortcut A Siri Shortcut! Built either by myself or another community member.
Projects
Status: No status
Development

No branches or pull requests

1 participant