@@ -6,6 +6,12 @@ Python-PlexAPI
6
6
:target: https://travis-ci.org/pkkid/python-plexapi
7
7
.. image :: https://coveralls.io/repos/github/pkkid/python-plexapi/badge.svg?branch=master
8
8
:target: https://coveralls.io/github/pkkid/python-plexapi?branch=master
9
+ .. image :: https://img.shields.io/github/tag/pkkid/python-plexapi.svg?label=github+release
10
+ :target: https://github.com/pkkid/python-plexapi/releases
11
+ .. image :: https://badge.fury.io/py/PlexAPI.svg
12
+ :target: https://badge.fury.io/py/PlexAPI
13
+ .. image :: https://img.shields.io/github/last-commit/pkkid/python-plexapi.svg
14
+ :target: https://img.shields.io/github/last-commit/pkkid/python-plexapi.svg
9
15
10
16
11
17
Overview
@@ -15,7 +21,7 @@ Plex Web Client. A few of the many features we currently support are:
15
21
16
22
* Navigate local or remote shared libraries.
17
23
* Perform library actions such as scan, analyze, empty trash.
18
- * Remote control and play media on connected clients.
24
+ * Remote control and play media on connected clients, including ` Controlling Sonos speakers `_
19
25
* Listen in on all Plex Server notifications.
20
26
21
27
@@ -118,48 +124,76 @@ Usage Examples
118
124
119
125
.. code-block :: python
120
126
121
- # Example 8: Get a URL to stream a movie or show in another client
122
- die_hard = plex.library.section(' Movies' ).get(' Elephants Dream' )
123
- print (' Run running the following command to play in VLC:' )
124
- print (' vlc "%s "' % die_hard.getStreamURL(videoResolution = ' 800x600' ))
127
+ # Example 8: Get audio/video/all playlists
128
+ for playlist in plex.playlists():
129
+ print (playlist.title)
125
130
126
131
127
132
.. code-block :: python
128
133
129
- # Example 9: Get audio/video/all playlists
130
- for playlist in plex.playlists():
131
- print (playlist.title)
134
+ # Example 9: Rate the 100 four stars.
135
+ plex.library.section(' TV Shows' ).get(' The 100' ).rate(8.0 )
136
+
137
+
138
+ Controlling Sonos speakers
139
+ --------------------------
140
+
141
+ To control Sonos speakers directly using Plex APIs, the following requirements must be met:
142
+
143
+ 1. Active Plex Pass subscription
144
+ 2. Sonos account linked to Plex account
145
+ 3. Plex remote access enabled
146
+
147
+ Due to the design of Sonos music services, the API calls to control Sonos speakers route through https://sonos.plex.tv
148
+ and back via the Plex server's remote access. Actual media playback is local unless networking restrictions prevent the
149
+ Sonos speakers from connecting to the Plex server directly.
150
+
151
+ .. code-block :: python
152
+
153
+ from plexapi.myplex import MyPlexAccount
154
+ from plexapi.server import PlexServer
155
+
156
+ baseurl = ' http://plexserver:32400'
157
+ token = ' 2ffLuB84dqLswk9skLos'
158
+
159
+ account = MyPlexAccount(token)
160
+ server = PlexServer(baseurl, token)
161
+
162
+ # List available speakers/groups
163
+ for speaker in account.sonos_speakers():
164
+ print (speaker.title)
165
+
166
+ # Obtain PlexSonosPlayer instance
167
+ speaker = account.sonos_speaker(" Kitchen" )
168
+
169
+ album = server.library.section(' Music' ).get(' Stevie Wonder' ).album(' Innervisions' )
170
+
171
+ # Speaker control examples
172
+ speaker.playMedia(album)
173
+ speaker.pause()
174
+ speaker.setVolume(10 )
175
+ speaker.skipNext()
132
176
133
177
134
178
Running tests over PlexAPI
135
179
--------------------------
136
180
137
- In order to test the PlexAPI library you have to prepare a Plex Server instance with following libraries:
138
-
139
- 1. Movies section (agent `com.plexapp.agents.imdb `) containing both movies:
140
- * Sintel - https://durian.blender.org/
141
- * Elephants Dream - https://orange.blender.org/
142
- * Sita Sings the Blues - http://www.sitasingstheblues.com/
143
- * Big Buck Bunny - https://peach.blender.org/
144
- 2. TV Show section (agent `com.plexapp.agents.thetvdb `) containing the shows:
145
- * Game of Thrones (Season 1 and 2)
146
- * The 100 (Seasons 1 and 2)
147
- * (or symlink the above movies with proper names)
148
- 3. Music section (agent `com.plexapp.agents.lastfm `) containing the albums:
149
- * Infinite State - Unmastered Impulses - https://github.com/kennethreitz/unmastered-impulses
150
- * Broke For Free - Layers - http://freemusicarchive.org/music/broke_for_free/Layers/
151
- 4. A Photos section (any agent) containing the photoalbums (photoalbum is just a folder on your disk):
152
- * `Cats `
153
- * Within `Cats ` album you need to place 3 photos (cute cat photos, of course)
154
- * Within `Cats ` album you should place 3 more photoalbums (one of them should be named `Cats in bed `,
155
- names of others doesn't matter)
156
- * Within `Cats in bed ` you need to place 7 photos
157
- * Within other 2 albums you should place 1 photo in each
158
-
159
- Instead of manual creation of the library you could use a script `tools/plex-boostraptest.py ` with appropriate
181
+ Use:
182
+
183
+ .. code-block :: bash
184
+
185
+ tools/plex-boostraptest.py
186
+
187
+ with appropriate
160
188
arguments and add this new server to a shared user which username is defined in environment veriable `SHARED_USERNAME `.
161
189
It uses `official docker image `_ to create a proper instance.
162
190
191
+ For skipping the docker and reuse a existing server use
192
+
193
+ .. code-block :: bash
194
+
195
+ python plex-boostraptest.py --no-docker -username USERNAME --password PASSWORD --server-name NAME-OF-YOUR-SEVER
196
+
163
197
Also in order to run most of the tests you have to provide some environment variables:
164
198
165
199
* `PLEXAPI_AUTH_SERVER_BASEURL ` containing an URL to your Plex instance, e.g. `http://127.0.0.1:32400 ` (without trailing
0 commit comments