Skip to content

Instantly share code, notes, and snippets.

@ghuntley
Created January 6, 2014 08:41
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ghuntley/8279917 to your computer and use it in GitHub Desktop.
Save ghuntley/8279917 to your computer and use it in GitHub Desktop.
plex media server library refresh all libraries.
#!/usr/bin/env python
import urllib
from xml.dom import minidom
host = 'localhost'
source_type = ['movie', 'show'] # Valid values: artist (for music), movie, show (for tv)
base_url = 'http://%s:32400/library/sections' % host
refresh_url = '%s/%%s/refresh?force=1' % base_url
try:
xml_sections = minidom.parse(urllib.urlopen(base_url))
sections = xml_sections.getElementsByTagName('Directory')
for s in sections:
if s.getAttribute('type') in source_type:
url = refresh_url % s.getAttribute('key')
x = urllib.urlopen(url)
except:
pass
#!/usr/bin/env python
import urllib
from xml.dom import minidom
host = 'localhost'
source_type = ['movie', 'show'] # Valid values: artist (for music), movie, show (for tv)
base_url = 'http://%s:32400/library/sections' % host
refresh_url = '%s/%%s/refresh' % base_url
try:
xml_sections = minidom.parse(urllib.urlopen(base_url))
sections = xml_sections.getElementsByTagName('Directory')
for s in sections:
if s.getAttribute('type') in source_type:
url = refresh_url % s.getAttribute('key')
x = urllib.urlopen(url)
except:
pass
@michealespinola
Copy link

There is no need to do per section if your intent is to refresh all. Example:

/library/sections/all/refresh?force=1

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