question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Alter Plex to refresh specific directories

See original GitHub issue

Thanks to the recent updates to postRadarr.py and postSonarr.py, sickbeard_mp4_automator is functioning flawlessly for imports now. The last remaining issue for me is because I am using plexdrive to mount my media on Google Drive.

If possible, it would be great if the default Plex refresh behavior could be altered to refresh only the new directory instead of the whole library on each import. This would help to reduce the number of API calls made to Google Drive on Plex’s behalf. I know plex_autoscan has implemented this by simply modifying the command line switches passed to Plex Media Scanner and I would imagine a similar implementation may be possible for autoprocess/plex.py.

Let me know if you have any questions or need help testing! Thanks!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
andrewkhunncommented, Jul 20, 2018

Alright, I figured out how to turn on debugging via stdout and I believe I got everthing working. I ran into a few issues:

  1. Forgot to chmod the script 775
  2. There were some indentation issues copy/pasting from here
  3. Lines 17 & 18 above were malformed

The fixed script is attached below for others:

#!/usr/bin/python
import os
import json
import requests

def main():
  print("plex_autoscan Post-processing Script")
  url = "http://localhost:3689/apikey"

  files = json.loads(os.environ.get('MH_FILES'))
  if not (files):
    print("Error - Did not find environment variables.")
    return

  for filename in files:
    dirname = os.path.dirname(filename)
    payload = {'eventType': 'Manual', 'filepath': dirname}
    try:
      requests.post(url, json=payload)
    except Exception as e:
      print("Error - Request failed")
      print(e)

if __name__ == "__main__":
  main()

Thanks again so much for your help assembling this thing!

0reactions
mdhigginscommented, Jul 20, 2018

👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Scanning vs Refreshing a Library - Support - Plex
It's possible to Refresh specific items. These can be individual items (a specific movie or TV episode) or containing elements such as a...
Read more >
How To Force a Refresh in Plex - Tech Junkie
Go to the main screen where your libraries are listed on the left. Select the '…' icon in the top of the left...
Read more >
Best practice for changing folder structure? : r/PleX - Reddit
Setup your new folder structure within your current folder. Then rescan, Plex will map the new locations for you and preserve the metadata....
Read more >
How to Move Plex's Temporary Files & Cache Directory
When you build up a big, multi-terabyte Plex Media Server library, Plex starts to fill up your C:\ drive with a LOT of...
Read more >
How do I refresh Plex library? - Remodel or Move
If you are trying to update home videos or photos, you will need to go to each particular folder or album respectively and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found