Merge pull request #123 from Hellowlol/pkkid/opt

add deleteMediaPreview
This commit is contained in:
Michael Shepanski 2017-02-19 22:48:41 -05:00 committed by GitHub
commit ebdc875a06
4 changed files with 33 additions and 4 deletions

View file

@ -222,4 +222,4 @@ pseudoxml:
dummy: dummy:
$(SPHINXBUILD) -b dummy $(ALLSPHINXOPTS) $(BUILDDIR)/dummy $(SPHINXBUILD) -b dummy $(ALLSPHINXOPTS) $(BUILDDIR)/dummy
@echo @echo
@echo "Build finished. Dummy builder generates no files." @echo "Build finished. Dummy builder generates no files."

View file

@ -137,6 +137,14 @@ class Library(PlexObject):
""" """
self._server.query('/library/sections/all/refresh?force=1') self._server.query('/library/sections/all/refresh?force=1')
def deleteMediaPreview(self):
""" Delete the preview thumbnails for the all librarys.
This cannot be undone. Recreating media preview files can take hours
or even days.
"""
for section in self.sections():
section.deleteMediaPreview()
class LibrarySection(PlexObject): class LibrarySection(PlexObject):
""" Base class for a single library section. """ Base class for a single library section.
@ -253,6 +261,14 @@ class LibrarySection(PlexObject):
key = '/library/sections/%s/refresh?force=1' % self.key key = '/library/sections/%s/refresh?force=1' % self.key
self._server.query(key) self._server.query(key)
def deleteMediaPreview(self):
""" Delete the preview thumbnails for items in this library
This cannot be undone. Recreating media preview files can take hours
or even days.
"""
key = '/library/sections/%s/indexes' % self.key
self._server.query(key, method=self._server._session.delete)
def listChoices(self, category, libtype=None, **kwargs): def listChoices(self, category, libtype=None, **kwargs):
""" Returns a list of :class:`~plexapi.library.FilterChoice` objects for the """ Returns a list of :class:`~plexapi.library.FilterChoice` objects for the
specified category and libtype. kwargs can be any of the same kwargs in specified category and libtype. kwargs can be any of the same kwargs in

View file

@ -1,10 +1,16 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import shlex, subprocess import os
from os.path import abspath, dirname, join import shlex
import subprocess
import pytest
# Uncomments when a make.bat file has been added to docs.
#@pytest.mark.xfail("os.environ.get('PLEX_TEST_TOKEN') is None",
# reason='Allow this to fail but not for devs or travis')
@pytest.mark.skipif(os.name == 'nt',
reason='Skipping this test for windows as there there is no make.bat.')
def test_build_documentation(): def test_build_documentation():
# TODO: assert no WARNING messages in sphinx output
docroot = join(dirname(dirname(abspath(__file__))), 'docs') docroot = join(dirname(dirname(abspath(__file__))), 'docs')
cmd = shlex.split('/usr/bin/make html --warn-undefined-variables') cmd = shlex.split('/usr/bin/make html --warn-undefined-variables')
proc = subprocess.Popen(cmd, cwd=docroot) proc = subprocess.Popen(cmd, cwd=docroot)

View file

@ -99,6 +99,10 @@ def test_library_Library_cancelUpdate(pms):
pms.library.cancelUpdate() pms.library.cancelUpdate()
def test_library_Library_deleteMediaPreview(pms):
pms.library.deleteMediaPreview()
def _test_library_MovieSection_refresh(a_movie_section): def _test_library_MovieSection_refresh(a_movie_section):
a_movie_section.refresh() a_movie_section.refresh()
@ -110,6 +114,9 @@ def test_library_MovieSection_update(a_movie_section):
def test_library_MovieSection_cancelUpdate(a_movie_section): def test_library_MovieSection_cancelUpdate(a_movie_section):
a_movie_section.cancelUpdate() a_movie_section.cancelUpdate()
def test_librarty_deleteMediaPreview(a_movie_section):
a_movie_section.deleteMediaPreview()
def _test_library_MovieSection_refresh(a_movie_section): def _test_library_MovieSection_refresh(a_movie_section):
a_movie_section.refresh() # check how much this breaks test before enabling it. a_movie_section.refresh() # check how much this breaks test before enabling it.