Channels Helper bookmarklet for working with Manage Lineup

I'm seeing an issue with the URL for the API pull to populate the descriptions.

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://api.pluto.tv/v2/channels. (Reason: CORS header ‘Access-Control-Allow-Origin’ does not match ‘http://pluto.tv’).
Problem fetching pluto channels listing: TypeError: NetworkError when attempting to fetch resource.

Here's the headers with the CORS for the GET http://api.pluto.tv/v2/channels:

Status 200 OK
Version HTTP/1.1
Transferred 33.35 kB (361.55 kB size)
Referrer Policystrict-origin-when-cross-origin
DNS ResolutionSystem
HTTP/1.1 200 OK
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Date: Sat, 13 Apr 2024 16:56:29 GMT
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Accept,Authorization,Content-Type,If-None-Match,X-Requested-With,X-Request-ID,X-Log-Level-Override,X-Forwarded-For,X-Search-Transaction
Access-Control-Allow-Methods: GET,PUT,POST,DELETE
Access-Control-Allow-Origin: http://pluto.tv
Access-Control-Expose-Headers: WWW-Authenticate,Server-Authorization,ETag
Access-Control-Max-Age: 1728000
Cache-Control: max-age=600, no-cache
Content-Encoding: gzip
Etag: djEvMTcyLjkwLjY5LjEyMi8vLzE3MTMwMjYwMjI2NTkwOTQwMDA=
Vary: Accept-Encoding
X-Connection-Id: 5425ee9a-a23e-40b0-8501-50eb6de97627
X-Request-Id: 7bb51e1b-5ade-40c7-bd6c-8f4b500cf836
X-Cache: Miss from cloudfront
Via: 1.1 92360e9adbf6cc1c5721d7fbaf6aad46.cloudfront.net (CloudFront)

Awesome!
Makes it so much easier to see what I want to block or keep.

Now @joagomez just needs to add group-title to his maddox compatible playlist and i.mjh.nz for those using it

1 Like

So I was finally able to recreate this, but it's a weird one. The Pluto API responds with a different value for the Access-Control-Allow-Origin header if the originating host looks to be from a local network AND contains a port# on the end. You can test this via devtools on any website by simply pasting this into the console:
await fetch('https://api.pluto.tv/v2/channels');

I get a CORS error because Pluto responds with "http://pluto.tv" required pretty much everywhere EXCEPT a site on a local network IP with a port where it responds with current host value. For example:
https://198.168.100.100 -> CORS error; returned http://pluto.tv
https://myserver.local -> CORS error; returned http://pluto.tv
https://google.com -> CORS error; returned http://pluto.tv
https://192.168.100.100:8089 -> NO CORS error; returned https://192.168.100.100:8089

I'm guessing maybe Pluto is doing some kind of dynamic allow-origin for what it assumes is dev purposes maybe if it's a local ip + port?

So my question to you is, what kind of URL are you accessing your Channels server with? i.e. http://192.168.* or an alias, with/without a port#, etc?

1 Like

Now did you use your manners? :blush: (I have young kids can’t resist)

No, seriously did I forget to add it to the compatible version? Sorry will take care of that after my day of kids soccer

1 Like

Please Dad.
Thanks in advance.

update has been uploaded

Thanks, but I'm waiting for v1.10b that has group-title in the maddox compatible playlist

1 Like

well sonuva... too many compatibles in this one. try now

1 Like

http://<MySynoDomain>.myds.me:8089/admin/settings/status

I've recently changed to use the myds.me domain with a split-horizon DNS so it resolves correctly depending on LAN or WAN access. I had previously used the bare IP address with port. And to confirm your confirmations, accessing the sources channels listings via IP address does show the channel descriptions as intended.

1 Like

Good to know! Sadly, I don't think there's much I can do about the CORS issue as it's really controlled by the API owner (Pluto). I will add a note at the top of the code indicating it's a known issue/limitation.

I'm glad you at least have the option of using the IP/port if you need it. Also, I'm not sure what you're using for your m3u source, but it sounds like some of the guys doing the docker containers are starting to include the description. If it's there locally, the code will just use it and not have to call out to the Pluto API.

Thanks for reporting the issue though!

1 Like

@dschaper Do you have this running with Tampermonkey? I've spent a few minutes on it today, and everything looks as expected including the Tampermonkey extension showing it has access to the CDVR Sources page -- but the code isn't doing its thing in the Manage Lineup pop out.

Is there something else I need to do in the top section:

// ==UserScript==
// @name         CDVR Sources Channel Manager
// @namespace    http://tampermonkey.net/
// @version      2024-05-12
// @description  try to take over the world!
// @author       You
// @match        http://media-server6:8089/admin/settings/sources
// @icon         https://www.google.com/s2/favicons?sz=64&domain=undefined.media-server6
// @grant        none
// ==/UserScript==

It's been on my to-do list for awhile to come up with some instructions for using with Tampermonkey since it's been mentioned a couple of times. I'm assuming you'd need to wrapper it with some kind of mutationobserver type of code to watch for the modal to be opened.

If anyone has already done it let me know and I'll update the instructions and/or code. If not I'll try to find some time to look into it.

1 Like

In a continuing quest to consolidate great CDVR tweaks and extensions like this one (thanks @kman0!) into a single interface -- I've added this to OliveTin. Same basic idea as using a bookmarklet maker, but in this case the code has already been formatted and minified.

Click the OliveTin Action, and drag the code up to your bookmarks bar. Right-click followed by Edit to rename:

screenshot-htpc6-2024.05.14-13_11_34

I've set this Action up to be able to accommodate a Tampermonkey version, if/when it becomes available.

2 Likes

@kman0, this bookmarklet is amazing! I haven't tried all of the functions. The ones I have used are so helpful. Thank you so much! :smiley:

I've installed code from GitHub before with no issues but creating a bookmarklet is new to me. I'm having difficulty installing this bookmarklet. YouTube examples are not helping. I'm guessing I'm missing something obvious. Could someone please point me to a some instructions?

Thanks!

Quote from https://gist.github.com/KennethScott/fd898f357d27d46a727d0d14ef6166f9

Recommended instructions for creating the bookmarklet using Bookmarklet Maker

  1. Copy & paste this code into the Code box. *Make sure to clear the "alert('hello world');" example code before pasting.
  2. Click the "Generate Bookmarlet" button
  3. Drag the blue-highlighted link button to your Bookmarks (and rename if you wish). You can simply ignore the
    "Output" and "Html code" boxes entirely.
2 Likes

Thank you!!
Silly me, I didn’t think to look inside the code.

:man_facepalming:

OliveTin-for-Channels includes an option to create this bookmarklet as well. Very easy to use.

1 Like

A quick scan of the threads for OliveTin-for-Channels seems to show that it's Linux based. My Channels instance is Windows based. My Plex server is Linux based. I would have already migrated Channels to Linux but the time required might cause me to miss some scheduled recordings.
Bottom line - Is OliveTin-for-Channels strictly Linux based?

Thanks!

No it's Docker-based, so it'll run on any platform where Docker can be installed. This includes Windows, MacOS and Linux.

The other important thing for you to know, is that OliveTin-for-Channels does not need to be installed on the same platform you're running Channels on. In fact, that's the way I have mine set up, Channels is running under Windows -- but all of my Docker containers run on a Linux host.

2 Likes