Plex - 429 Too Many Requests

Would you be willing to share that setup for those of us less technically savvy?

1 Like

Do you might outlining how it works? Also, is there a /config or some other directory mapping for appdata?

Thanks, I have been pulling out what little hair I have left over this on another platform.

I went the sed route:

here is the script:

#!/bin/sed -f
#
# Make executable via chmod +x <scriptname>
#
# <scriptname> Plex-all.m3u8 > new-playlistname
#

#
s;https://i.mjh.nz/Plex/\(.*\);https://epg.provider.plex.tv/library/parts/\1?X-Plex-Client-Identifier=xgkz9ui5tipdsflhzmh1ar3h\&X-Plex-Client-Platform=Chrome\&X-Plex-Token=YOUR-PLEX-TOKEN-HERE;
1 Like

I've been working to try and simplify things as much as possible. Came up with two scripts...
A run once script to generate user unique data for Plex, and register Channels DVR as an app with Plex access.
A second script to take that data and update the i.mjh.nz files. It's currently set up for 'us' only, but could be edited to pull another set of data.

I'll try and get it up somewhere later today. But....I'm a Linux guy, haven't really touched Windows in a long time. Especially to try and translate the bash script into bat/cmd.

1 Like

This would be awesome. Running Channels as a container in Unraid, so I can likely use User Scripts to schedule this, too.

I made an attempt.....the scripts are up on gist

4 Likes

Thanks for doing that. I guess I need it dumbed down some more. I get a plexdata file with the USERID,SESSIONID, and CLIENTID, but TOKEN line is empty. When I click on the plextoken file it's empty. It's not easy for me to pass runtime arguments using Unraid's User Scripts plugin, so I just set USERID and PASSWD as variables in the script. Maybe that's the issue. Not sure, I'll keep trying.

1 Like

Does you plex password have any special characters in it?

Yes. It was my theory that was an issue, but as they require at least one special character now I thought that might be noted. Sounds like I got bit by assumptions? :slight_smile: Guess I'll work on figuring out the correct encoding to try it out.

I've had plex for a long time and my pw doesn't have special characters....I thought about that and hoped for the best :frowning_face:

Let me see if can figure it out.

That thought also crossed my mind, LOL. My main account has 2FA and that stumped me first, so I created a new account as I just watch streams - Jellyfin is my main media server. So yeah, I think it is a newer requirement.

1 Like

What you may try is escaping the chars yourself. Insert a backslash \ before each special character.

That generated a token - THANK YOU!

Great! I'll work on an update.

EDIT:
Turns out there was a simple fix....just the instructions updated
Syntax:
USERID='[your plex email]' PASSWD='[your plex passwd]' [path_to_script/plextoken.sh]
Note that your email and passwd must be placed in single quotes to ensure correct handling of special characters

EDIT:
Also added a check for a failed attempt to obtain a token

1 Like

Got the PlexIPTV.sh script working first try after you helped me with this. I just finished watching Plex for about 5 minutes - something I haven't been able to do for several days to a couple of weeks.

1 Like

Thanks for testing this out! Appreciate it.
If anything else comes up i'll be periodically checking this thread.

1 Like

I was thinking about Windows, and I think you could run these scripts under WSL if you have it installed.

The only thing I vaguely remember from when I was using Windows Channels and running programs in WSL is that WSL had trouble communicating with the Channels server using the localhost address. You had to use your actual network address (change in PlexIPTV.sh). You will also need to change the File names in the Channels source definition to Windows format.

3 Likes

I've given the @john9527 scripts (thanks!) the OliveTin-for-Channels treatment, both for generating the unique Plex token and creating the user-specific M3U/XML. One of the variations deploying this via OliveTin, is that's not necessary to have the script on the same host as your Channels DVR.

A cron job is not needed either, as the OliveTin Action will repeat at whatever interval you specify. A healthchecks.io integration is available, so you'll get notified by e-mail if the Plex data is not refreshed on the schedule set.

In addition, I've added a static-file-server to the stack, so that the resulting M3U and XML files are available by URL. Multiple DVRs are supported too, if needed, though you can share the files generated across DVRs as well.

screenshot-htpc6-2024.01.07-05_39_18

screenshot-htpc6-2024.01.07-05_40_04

Healthchecks.io integration if you're using Organizr for CDVR related stuff:

And, of course, the end result:

Here's the full stack (including static-file-server) to deploy via Portainer:

version: '3.9'
services:
  olivetin:
    image: bnhf/olivetin:${TAG} # Add the tag like latest or test to the environment variables below
    container_name: olivetin
    dns_search: ${DOMAIN} # For Tailscale users using Magic DNS, add your Tailnet (tailxxxxx.ts.net) to use hostnames for remote nodes
    ports:
      - 1337:1337
    environment:
      - CHANNELS_DVR=${CHANNELS_DVR} # Add your Channels DVR server in the form hostname:port or ip:port
      - CHANNELS_DVR_ALTERNATES=${CHANNELS_DVR_ALTERNATES} # Space separated list of alternate Channels DVR servers to choose from in the form hostname:port or ip:port
      - CHANNELS_CLIENTS=${CHANNELS_CLIENTS} # Space separated list of Channels DVR clients you'd like notifications sent to in the form hostname or IP
      - UPDATE_YAMLS=${UPDATE_YAMLS} # Set this to true to update config.yaml
      - UPDATE_SCRIPTS=${UPDATE_SCRIPTS} # Set this to true to update all included scripts
      - TZ=${TZ} # Add your local timezone in standard linux format. E.G. US/Eastern, US/Central, US/Mountain, US/Pacific, etc
    volumes:
      - ${HOST_DIR}/olivetin:/config # Add the parent directory on your Docker you'd like to use
      - ${DVR_SHARE}:/mnt/media-server6-8089 # This can either be a Docker volume or a host directory that's connected via Samba or NFS to your Channels DVR network share
    restart: unless-stopped
#volumes: # use this section if you've setup a docker volume named channels-dvr, with CIFS or NFS, to bind to /mnt/dvr inside the container
  #channels-dvr:
    #external: true
    
  static-file-server:
    image: halverneus/static-file-server:${TAG}
    container_name: static-file-server
    dns_search: ${DOMAIN}
    ports:
      - 8080:8080
    environment:
      - FOLDER=${FOLDER}
    volumes:
      - ${HOST_DIR}/olivetin/local-server-8089_data:${FOLDER}
    restart: unless-stopped

And some sample environment variables:

TAG=latest
DOMAIN=tailxxxxx.ts.net
CHANNELS_DVR=local-server:8089
CHANNELS_DVR_ALTERNATES=remote-server:8089
CHANNELS_CLIENTS=appletv4k-den firestick-bedroom
UPDATE_YAMLS=true
UPDATE_SCRIPTS=true
TZ=US/Mountain
HOST_DIR=/data
DVR_SHARE=/mnt/dvr
FOLDER=/web

Using the above example, the Plex M3U could be found at http://your-docker-host:8080/us.m3u8, and the XML could be found at http://your-docker-host:8080/us.xml -- and would look like this in Custom Channels:

6 Likes

nice! thanks for these scripts, @john9527

I do confirm that these scripts will work in WSL.

Issues I encountered:

If you cron the PlexIPTV.sh script, the cron service in WSL is disabled by default so you'd have to set up a task in task scheduler to start it on startup. but then if you ran docker in WSL for the plutotv guide container, you're probably already doing this so just add it to that. I suppose alternately, you could simply just use task scheduler to kick off the actual script in wsl instead of cron.

I'm not sure if its an IP issue or if simply the URL being referenced to in PlexIPTV.sh is not in the same place, but after fiddling with this a little, I simply circumvented it and went the local file route as my WSL mounts the C drive in /mnt/c anyway. So, I modded the scripts to create/write to /mnt/c/ChannelsDVR/IPTV/plex and referenced the same place in the source settings in the channels gui, but correcting to C:\ChannelsDVR\IPTV\plex for the relevant paths.

1 Like

The plextoken.sh script did not work for me because of Special Chars being present, and yes I used the Single Quotes as advised. I had to URL encode the passwd first.

Consider updating your script to include something like:

# If receiving script errors and your passwd contains special characters, 
# try using a version of your passwd that is URL ENCODEd
# ( e.g., generated with https://www.browserling.com/tools/url-encode  or similar)