Skip to content

Instantly share code, notes, and snippets.

@favoyang
Last active December 2, 2021 09:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save favoyang/d174ef028e428dbfe230fc418c8b555b to your computer and use it in GitHub Desktop.
Save favoyang/d174ef028e428dbfe230fc418c8b555b to your computer and use it in GitHub Desktop.
The guideline to set up Plex to access scraper API via proxy on macOS

The Guideline to Setup Plex to Access Scraper API via Proxy on macOS

Similar questions:

This post helps you set up plex to access scraper API (thetvdb for example) via your proxy on macOS. Plex doesn't respect the system-level sock proxy (in Network settings), but it respects the HTTP_PROXY and HTTPS_PROXY variables.

Step l: Set up your HTTP proxy app and configure the scraper domains (thetvdb.com for example).

Because we're going to set up the system-level HTTP_PROXY variable below. It's better to configure your proxy to only the desired domains, so it won't affect other apps.

Test your proxy app.

HTTPS_PROXY=https://127.0.0.1:7070 curl -I https://thetvdb.com
...
HTTP/2 200

Step 2: Add the system-level HTTP_PROXY and HTTPS_PROXY variables.

http://127.0.0.1:7070 is the example proxy address.

Set once for testing:

launchctl setenv HTTP_PROXY http://127.0.0.1:7070
launchctl setenv HTTPS_PROXY http://127.0.0.1:7070

To make it presistent, create an my.environments.plist file in ~/Library/LaunchAgents/ with this content:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>my.environments</string>
  <key>ProgramArguments</key>
  <array>
    <string>sh</string>
    <string>-c</string>
    <string>
    launchctl setenv HTTP_PROXY http://127.0.0.1:7070
    launchctl setenv HTTPS_PROXY http://127.0.0.1:7070
    </string>
  </array>
  <key>RunAtLoad</key>
  <true/>
</dict>
</plist>

Load it the plist file

launchctl load ~/Library/LaunchAgents/my.environments.plist

Verify it

launchctl list | grep my.environments
-     0     my.environments

Open a new terminal app and print the env

env|grep HTTP
HTTP_PROXY http://127.0.0.1:7070
HTTPS_PROXY http://127.0.0.1:7070

Step 3: Restart the plex and rematch a media via the desired scraper API.

Find a media file and remtach it with the desired scraper api. It should just work.

Double-check the Plex logs. Locate the log files: https://support.plex.tv/articles/200250417-plex-media-server-log-files/.

~/Library/Logs/Plex Media Server/PMS Plugin Logs/com.plexapp.agents.thetvdb.log

Open it and navigate to the end, you will see below.

... Requesting 'https://artworks.thetvdb.com/banners/.....jpg`
... Not caching .....

If anything goes incorrect you will see a timeout after the request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment