python-plexapi icon indicating copy to clipboard operation
python-plexapi copied to clipboard

Add support for using `MediaTag` objects when editing tags

Open JonnyWong16 opened this issue 3 years ago • 0 comments

Description

Add support for using MediaTag objects when editing tags. Using tag strings is still supported.

Examples

Previously editing tags required providing the tag strings.

>>> movie.genres
[<Genre:77:Drama>, <Genre:3070:Action>, <Genre:3952:Crime>, <Genre:79:Thriller>]
>>> movie.removeGenre([genre.tag for genre in movies.genres[2:]]).reload()
>>> movie.genres
[<Genre:77:Drama>, <Genre:3070:Action>]

Now it can be simplified by using the MediaTag objects directly.

>>> movie.genres
[<Genre:77:Drama>, <Genre:3070:Action>, <Genre:3952:Crime>, <Genre:79:Thriller>]
>>> movie.removeGenre(movies.genres[2:]).reload()
>>> movie.genres
[<Genre:77:Drama>, <Genre:3070:Action>]

Or adding tags from another object.

>>> tvshow.genres
[<Genre:154:Fantasy>]
>>> movie.genres
[<Genre:77:Drama>, <Genre:3070:Action>, <Genre:3952:Crime>, <Genre:79:Thriller>]
>>> movie.addGenre(tvshow.genres).reload()
>>> moive.genres
[<Genre:77:Drama>, <Genre:3070:Action>, <Genre:3952:Crime>, <Genre:79:Thriller>, <Genre:154:Fantasy>]

Type of change

Please delete options that are not relevant.

  • [x] New feature (non-breaking change which adds functionality)
  • [x] This change requires a documentation update

Checklist:

  • [x] My code follows the style guidelines of this project
  • [x] I have performed a self-review of my own code
  • [ ] I have commented my code, particularly in hard-to-understand areas
  • [x] I have added or updated the docstring for new or existing methods
  • [x] I have added tests when applicable

JonnyWong16 avatar Jul 24 '22 23:07 JonnyWong16