Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to upload theme music #658

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions plexapi/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,25 @@ def download(self, savepath=None, keep_original_name=False, **kwargs):
for track in album.tracks():
filepaths += track.download(savepath, keep_original_name, **kwargs)
return filepaths

def themes(self):
""" Returns list of available theme objects. :class:`~plexapi.media.Theme`. """

return self.fetchItems('%s/themes' % self.key)

def uploadTheme(self, url=None, filepath=None):
""" Upload theme from url or filepath. :class:`~plexapi.media.Theme` to :class:`~plexapi.video.Video`. """
if url:
key = '%s/themes?url=%s' % (self.key, quote_plus(url))
self._server.query(key, method=self._server._session.post)
elif filepath:
key = '%s/themes?' % self.key
data = open(filepath, 'rb').read()
self._server.query(key, method=self._server._session.post, data=data)

def setTheme(self, theme):
""" Set . :class:`~plexapi.media.Theme` to :class:`~plexapi.video.Video` """
theme.select()


@utils.registerPlexObject
Expand Down
6 changes: 3 additions & 3 deletions plexapi/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,12 +555,12 @@ def setPoster(self, poster):
poster.select()

def arts(self):
""" Returns list of available art objects. :class:`~plexapi.media.Poster`. """
""" Returns list of available art objects. :class:`~plexapi.media.Art`. """

return self.fetchItems('%s/arts' % self.key)

def uploadArt(self, url=None, filepath=None):
""" Upload art from url or filepath. :class:`~plexapi.media.Poster` to :class:`~plexapi.video.Video`. """
""" Upload art from url or filepath. :class:`~plexapi.media.Art` to :class:`~plexapi.video.Video`. """
if url:
key = '/library/metadata/%s/arts?url=%s' % (self.ratingKey, quote_plus(url))
self._server.query(key, method=self._server._session.post)
Expand All @@ -570,7 +570,7 @@ def uploadArt(self, url=None, filepath=None):
self._server.query(key, method=self._server._session.post, data=data)

def setArt(self, art):
""" Set :class:`~plexapi.media.Poster` to :class:`~plexapi.video.Video` """
""" Set :class:`~plexapi.media.Art` to :class:`~plexapi.video.Video` """
art.select()

def unmatch(self):
Expand Down
38 changes: 38 additions & 0 deletions plexapi/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,25 @@ def download(self, savepath=None, keep_original_name=False, **kwargs):
if filepath:
filepaths.append(filepath)
return filepaths

def themes(self):
""" Returns list of available theme objects. :class:`~plexapi.media.Theme`. """

return self.fetchItems('%s/themes' % self.key)

def uploadTheme(self, url=None, filepath=None):
""" Upload theme from url or filepath. :class:`~plexapi.media.Theme` to :class:`~plexapi.video.Video`. """
if url:
key = '%s/themes?url=%s' % (self.key, quote_plus(url))
self._server.query(key, method=self._server._session.post)
elif filepath:
key = '%s/themes?' % self.key
data = open(filepath, 'rb').read()
self._server.query(key, method=self._server._session.post, data=data)

def setTheme(self, theme):
""" Set . :class:`~plexapi.media.Theme` to :class:`~plexapi.video.Video` """
theme.select()


@utils.registerPlexObject
Expand Down Expand Up @@ -580,6 +599,25 @@ def download(self, savepath=None, keep_original_name=False, **kwargs):
for episode in self.episodes():
filepaths += episode.download(savepath, keep_original_name, **kwargs)
return filepaths

def themes(self):
""" Returns list of available theme objects. :class:`~plexapi.media.Theme`. """

return self.fetchItems('%s/themes' % self.key)

def uploadTheme(self, url=None, filepath=None):
""" Upload theme from url or filepath. :class:`~plexapi.media.Theme` to :class:`~plexapi.video.Video`. """
if url:
key = '%s/themes?url=%s' % (self.key, quote_plus(url))
self._server.query(key, method=self._server._session.post)
elif filepath:
key = '%s/themes?' % self.key
data = open(filepath, 'rb').read()
self._server.query(key, method=self._server._session.post, data=data)

def setTheme(self, theme):
""" Set . :class:`~plexapi.media.Theme` to :class:`~plexapi.video.Video` """
theme.select()


@utils.registerPlexObject
Expand Down