2018-09-14 18:03:23 +00:00
|
|
|
from plexapi.exceptions import BadRequest
|
2020-04-29 21:23:22 +00:00
|
|
|
from plexapi.sync import (AUDIO_BITRATE_192_KBPS, PHOTO_QUALITY_MEDIUM,
|
|
|
|
VIDEO_QUALITY_3_MBPS_720p)
|
2018-09-08 15:25:16 +00:00
|
|
|
|
2020-04-29 21:23:22 +00:00
|
|
|
from . import conftest as utils
|
2018-09-08 15:25:16 +00:00
|
|
|
|
|
|
|
|
2020-12-07 01:21:47 +00:00
|
|
|
def get_sync_item_from_server(sync_device, sync_item):
|
|
|
|
sync_list = sync_device.syncItems()
|
2018-09-14 18:03:23 +00:00
|
|
|
for item in sync_list.items:
|
|
|
|
if item.id == sync_item.id:
|
|
|
|
return item
|
2018-09-08 15:25:16 +00:00
|
|
|
|
|
|
|
|
2020-12-07 01:21:47 +00:00
|
|
|
def is_sync_item_missing(sync_device, sync_item):
|
|
|
|
return not get_sync_item_from_server(sync_device, sync_item)
|
2018-09-08 15:25:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_current_device_got_sync_target(clear_sync_device):
|
2020-04-29 21:23:22 +00:00
|
|
|
assert "sync-target" in clear_sync_device.provides
|
2018-09-08 15:25:16 +00:00
|
|
|
|
|
|
|
|
2018-09-14 18:03:23 +00:00
|
|
|
def get_media(item, server):
|
|
|
|
try:
|
|
|
|
return item.getMedia()
|
|
|
|
except BadRequest as e:
|
2020-04-29 21:23:22 +00:00
|
|
|
if "not_found" in str(e):
|
2018-09-14 18:03:23 +00:00
|
|
|
server.refreshSync()
|
|
|
|
return None
|
|
|
|
else:
|
|
|
|
raise
|
|
|
|
|
|
|
|
|
2018-09-08 15:25:16 +00:00
|
|
|
def test_add_movie_to_sync(clear_sync_device, movie):
|
|
|
|
new_item = movie.sync(VIDEO_QUALITY_3_MBPS_720p, client=clear_sync_device)
|
|
|
|
movie._server.refreshSync()
|
2020-04-29 21:23:22 +00:00
|
|
|
item = utils.wait_until(
|
|
|
|
get_sync_item_from_server,
|
|
|
|
delay=0.5,
|
|
|
|
timeout=3,
|
2020-12-07 01:21:47 +00:00
|
|
|
sync_device=clear_sync_device,
|
2020-04-29 21:23:22 +00:00
|
|
|
sync_item=new_item,
|
|
|
|
)
|
|
|
|
media_list = utils.wait_until(
|
|
|
|
get_media, delay=0.25, timeout=3, item=item, server=movie._server
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
assert len(media_list) == 1
|
|
|
|
assert media_list[0].ratingKey == movie.ratingKey
|
|
|
|
|
|
|
|
|
|
|
|
def test_delete_sync_item(clear_sync_device, movie):
|
|
|
|
new_item = movie.sync(VIDEO_QUALITY_3_MBPS_720p, client=clear_sync_device)
|
|
|
|
movie._server.refreshSync()
|
2020-04-29 21:23:22 +00:00
|
|
|
new_item_in_myplex = utils.wait_until(
|
|
|
|
get_sync_item_from_server,
|
|
|
|
delay=0.5,
|
|
|
|
timeout=3,
|
2020-12-07 01:21:47 +00:00
|
|
|
sync_device=clear_sync_device,
|
2020-04-29 21:23:22 +00:00
|
|
|
sync_item=new_item,
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
sync_items = clear_sync_device.syncItems()
|
|
|
|
for item in sync_items.items:
|
|
|
|
item.delete()
|
2020-04-29 21:23:22 +00:00
|
|
|
utils.wait_until(
|
|
|
|
is_sync_item_missing,
|
|
|
|
delay=0.5,
|
|
|
|
timeout=3,
|
2020-12-07 01:21:47 +00:00
|
|
|
sync_device=clear_sync_device,
|
2020-04-29 21:23:22 +00:00
|
|
|
sync_item=new_item_in_myplex,
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_add_show_to_sync(clear_sync_device, show):
|
|
|
|
new_item = show.sync(VIDEO_QUALITY_3_MBPS_720p, client=clear_sync_device)
|
|
|
|
show._server.refreshSync()
|
2020-04-29 21:23:22 +00:00
|
|
|
item = utils.wait_until(
|
|
|
|
get_sync_item_from_server,
|
|
|
|
delay=0.5,
|
|
|
|
timeout=3,
|
2020-12-07 01:21:47 +00:00
|
|
|
sync_device=clear_sync_device,
|
2020-04-29 21:23:22 +00:00
|
|
|
sync_item=new_item,
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
episodes = show.episodes()
|
2020-04-29 21:23:22 +00:00
|
|
|
media_list = utils.wait_until(
|
|
|
|
get_media, delay=0.25, timeout=3, item=item, server=show._server
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
assert len(episodes) == len(media_list)
|
|
|
|
assert [e.ratingKey for e in episodes] == [m.ratingKey for m in media_list]
|
|
|
|
|
|
|
|
|
|
|
|
def test_add_season_to_sync(clear_sync_device, show):
|
2020-04-29 21:23:22 +00:00
|
|
|
season = show.season("Season 1")
|
2018-09-08 15:25:16 +00:00
|
|
|
new_item = season.sync(VIDEO_QUALITY_3_MBPS_720p, client=clear_sync_device)
|
|
|
|
season._server.refreshSync()
|
2020-04-29 21:23:22 +00:00
|
|
|
item = utils.wait_until(
|
|
|
|
get_sync_item_from_server,
|
|
|
|
delay=0.5,
|
|
|
|
timeout=3,
|
2020-12-07 01:21:47 +00:00
|
|
|
sync_device=clear_sync_device,
|
2020-04-29 21:23:22 +00:00
|
|
|
sync_item=new_item,
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
episodes = season.episodes()
|
2020-04-29 21:23:22 +00:00
|
|
|
media_list = utils.wait_until(
|
|
|
|
get_media, delay=0.25, timeout=3, item=item, server=season._server
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
assert len(episodes) == len(media_list)
|
|
|
|
assert [e.ratingKey for e in episodes] == [m.ratingKey for m in media_list]
|
|
|
|
|
|
|
|
|
|
|
|
def test_add_episode_to_sync(clear_sync_device, episode):
|
|
|
|
new_item = episode.sync(VIDEO_QUALITY_3_MBPS_720p, client=clear_sync_device)
|
|
|
|
episode._server.refreshSync()
|
2020-04-29 21:23:22 +00:00
|
|
|
item = utils.wait_until(
|
|
|
|
get_sync_item_from_server,
|
|
|
|
delay=0.5,
|
|
|
|
timeout=3,
|
2020-12-07 01:21:47 +00:00
|
|
|
sync_device=clear_sync_device,
|
2020-04-29 21:23:22 +00:00
|
|
|
sync_item=new_item,
|
|
|
|
)
|
|
|
|
media_list = utils.wait_until(
|
|
|
|
get_media, delay=0.25, timeout=3, item=item, server=episode._server
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
assert 1 == len(media_list)
|
|
|
|
assert episode.ratingKey == media_list[0].ratingKey
|
|
|
|
|
|
|
|
|
|
|
|
def test_limited_watched(clear_sync_device, show):
|
2022-08-26 19:14:24 +00:00
|
|
|
show.markUnplayed()
|
2020-04-29 21:23:22 +00:00
|
|
|
new_item = show.sync(
|
|
|
|
VIDEO_QUALITY_3_MBPS_720p, client=clear_sync_device, limit=5, unwatched=False
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
show._server.refreshSync()
|
2020-04-29 21:23:22 +00:00
|
|
|
item = utils.wait_until(
|
|
|
|
get_sync_item_from_server,
|
|
|
|
delay=0.5,
|
|
|
|
timeout=3,
|
2020-12-07 01:21:47 +00:00
|
|
|
sync_device=clear_sync_device,
|
2020-04-29 21:23:22 +00:00
|
|
|
sync_item=new_item,
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
episodes = show.episodes()[:5]
|
2020-04-29 21:23:22 +00:00
|
|
|
media_list = utils.wait_until(
|
|
|
|
get_media, delay=0.25, timeout=3, item=item, server=show._server
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
assert 5 == len(media_list)
|
|
|
|
assert [e.ratingKey for e in episodes] == [m.ratingKey for m in media_list]
|
2022-08-26 19:14:24 +00:00
|
|
|
episodes[0].markPlayed()
|
2018-09-08 15:25:16 +00:00
|
|
|
show._server.refreshSync()
|
2020-04-29 21:23:22 +00:00
|
|
|
media_list = utils.wait_until(
|
|
|
|
get_media, delay=0.25, timeout=3, item=item, server=show._server
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
assert 5 == len(media_list)
|
|
|
|
assert [e.ratingKey for e in episodes] == [m.ratingKey for m in media_list]
|
|
|
|
|
|
|
|
|
|
|
|
def test_limited_unwatched(clear_sync_device, show):
|
2022-08-26 19:14:24 +00:00
|
|
|
show.markUnplayed()
|
2020-04-29 21:23:22 +00:00
|
|
|
new_item = show.sync(
|
|
|
|
VIDEO_QUALITY_3_MBPS_720p, client=clear_sync_device, limit=5, unwatched=True
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
show._server.refreshSync()
|
2020-04-29 21:23:22 +00:00
|
|
|
item = utils.wait_until(
|
|
|
|
get_sync_item_from_server,
|
|
|
|
delay=0.5,
|
|
|
|
timeout=3,
|
2020-12-07 01:21:47 +00:00
|
|
|
sync_device=clear_sync_device,
|
2020-04-29 21:23:22 +00:00
|
|
|
sync_item=new_item,
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
episodes = show.episodes(viewCount=0)[:5]
|
2020-04-29 21:23:22 +00:00
|
|
|
media_list = utils.wait_until(
|
|
|
|
get_media, delay=0.25, timeout=3, item=item, server=show._server
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
assert len(episodes) == len(media_list)
|
|
|
|
assert [e.ratingKey for e in episodes] == [m.ratingKey for m in media_list]
|
2022-08-26 19:14:24 +00:00
|
|
|
episodes[0].markPlayed()
|
2018-09-08 15:25:16 +00:00
|
|
|
show._server.refreshSync()
|
|
|
|
episodes = show.episodes(viewCount=0)[:5]
|
2020-04-29 21:23:22 +00:00
|
|
|
media_list = utils.wait_until(
|
|
|
|
get_media, delay=0.25, timeout=3, item=item, server=show._server
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
assert len(episodes) == len(media_list)
|
|
|
|
assert [e.ratingKey for e in episodes] == [m.ratingKey for m in media_list]
|
|
|
|
|
|
|
|
|
|
|
|
def test_unlimited_and_watched(clear_sync_device, show):
|
2022-08-26 19:14:24 +00:00
|
|
|
show.markUnplayed()
|
2020-04-29 21:23:22 +00:00
|
|
|
new_item = show.sync(
|
|
|
|
VIDEO_QUALITY_3_MBPS_720p, client=clear_sync_device, unwatched=False
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
show._server.refreshSync()
|
2020-04-29 21:23:22 +00:00
|
|
|
item = utils.wait_until(
|
|
|
|
get_sync_item_from_server,
|
|
|
|
delay=0.5,
|
|
|
|
timeout=3,
|
2020-12-07 01:21:47 +00:00
|
|
|
sync_device=clear_sync_device,
|
2020-04-29 21:23:22 +00:00
|
|
|
sync_item=new_item,
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
episodes = show.episodes()
|
2020-04-29 21:23:22 +00:00
|
|
|
media_list = utils.wait_until(
|
|
|
|
get_media, delay=0.25, timeout=3, item=item, server=show._server
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
assert len(episodes) == len(media_list)
|
|
|
|
assert [e.ratingKey for e in episodes] == [m.ratingKey for m in media_list]
|
2022-08-26 19:14:24 +00:00
|
|
|
episodes[0].markPlayed()
|
2018-09-08 15:25:16 +00:00
|
|
|
show._server.refreshSync()
|
|
|
|
episodes = show.episodes()
|
2020-04-29 21:23:22 +00:00
|
|
|
media_list = utils.wait_until(
|
|
|
|
get_media, delay=0.25, timeout=3, item=item, server=show._server
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
assert len(episodes) == len(media_list)
|
|
|
|
assert [e.ratingKey for e in episodes] == [m.ratingKey for m in media_list]
|
|
|
|
|
|
|
|
|
|
|
|
def test_unlimited_and_unwatched(clear_sync_device, show):
|
2022-08-26 19:14:24 +00:00
|
|
|
show.markUnplayed()
|
2020-04-29 21:23:22 +00:00
|
|
|
new_item = show.sync(
|
|
|
|
VIDEO_QUALITY_3_MBPS_720p, client=clear_sync_device, unwatched=True
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
show._server.refreshSync()
|
2020-04-29 21:23:22 +00:00
|
|
|
item = utils.wait_until(
|
|
|
|
get_sync_item_from_server,
|
|
|
|
delay=0.5,
|
|
|
|
timeout=3,
|
2020-12-07 01:21:47 +00:00
|
|
|
sync_device=clear_sync_device,
|
2020-04-29 21:23:22 +00:00
|
|
|
sync_item=new_item,
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
episodes = show.episodes(viewCount=0)
|
2020-04-29 21:23:22 +00:00
|
|
|
media_list = utils.wait_until(
|
|
|
|
get_media, delay=0.25, timeout=3, item=item, server=show._server
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
assert len(episodes) == len(media_list)
|
|
|
|
assert [e.ratingKey for e in episodes] == [m.ratingKey for m in media_list]
|
2022-08-26 19:14:24 +00:00
|
|
|
episodes[0].markPlayed()
|
2018-09-08 15:25:16 +00:00
|
|
|
show._server.refreshSync()
|
|
|
|
episodes = show.episodes(viewCount=0)
|
2020-04-29 21:23:22 +00:00
|
|
|
media_list = utils.wait_until(
|
|
|
|
get_media, delay=0.25, timeout=3, item=item, server=show._server
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
assert len(episodes) == len(media_list)
|
|
|
|
assert [e.ratingKey for e in episodes] == [m.ratingKey for m in media_list]
|
|
|
|
|
|
|
|
|
|
|
|
def test_add_music_artist_to_sync(clear_sync_device, artist):
|
|
|
|
new_item = artist.sync(AUDIO_BITRATE_192_KBPS, client=clear_sync_device)
|
|
|
|
artist._server.refreshSync()
|
2020-04-29 21:23:22 +00:00
|
|
|
item = utils.wait_until(
|
|
|
|
get_sync_item_from_server,
|
|
|
|
delay=0.5,
|
|
|
|
timeout=3,
|
2020-12-07 01:21:47 +00:00
|
|
|
sync_device=clear_sync_device,
|
2020-04-29 21:23:22 +00:00
|
|
|
sync_item=new_item,
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
tracks = artist.tracks()
|
2020-04-29 21:23:22 +00:00
|
|
|
media_list = utils.wait_until(
|
|
|
|
get_media, delay=0.25, timeout=3, item=item, server=artist._server
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
assert len(tracks) == len(media_list)
|
|
|
|
assert [t.ratingKey for t in tracks] == [m.ratingKey for m in media_list]
|
|
|
|
|
|
|
|
|
|
|
|
def test_add_music_album_to_sync(clear_sync_device, album):
|
|
|
|
new_item = album.sync(AUDIO_BITRATE_192_KBPS, client=clear_sync_device)
|
|
|
|
album._server.refreshSync()
|
2020-04-29 21:23:22 +00:00
|
|
|
item = utils.wait_until(
|
|
|
|
get_sync_item_from_server,
|
|
|
|
delay=0.5,
|
|
|
|
timeout=3,
|
2020-12-07 01:21:47 +00:00
|
|
|
sync_device=clear_sync_device,
|
2020-04-29 21:23:22 +00:00
|
|
|
sync_item=new_item,
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
tracks = album.tracks()
|
2020-04-29 21:23:22 +00:00
|
|
|
media_list = utils.wait_until(
|
|
|
|
get_media, delay=0.25, timeout=3, item=item, server=album._server
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
assert len(tracks) == len(media_list)
|
|
|
|
assert [t.ratingKey for t in tracks] == [m.ratingKey for m in media_list]
|
|
|
|
|
|
|
|
|
|
|
|
def test_add_music_track_to_sync(clear_sync_device, track):
|
|
|
|
new_item = track.sync(AUDIO_BITRATE_192_KBPS, client=clear_sync_device)
|
|
|
|
track._server.refreshSync()
|
2020-04-29 21:23:22 +00:00
|
|
|
item = utils.wait_until(
|
|
|
|
get_sync_item_from_server,
|
|
|
|
delay=0.5,
|
|
|
|
timeout=3,
|
2020-12-07 01:21:47 +00:00
|
|
|
sync_device=clear_sync_device,
|
2020-04-29 21:23:22 +00:00
|
|
|
sync_item=new_item,
|
|
|
|
)
|
|
|
|
media_list = utils.wait_until(
|
|
|
|
get_media, delay=0.25, timeout=3, item=item, server=track._server
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
assert 1 == len(media_list)
|
|
|
|
assert track.ratingKey == media_list[0].ratingKey
|
|
|
|
|
|
|
|
|
2018-09-14 18:03:23 +00:00
|
|
|
def test_add_photo_to_sync(clear_sync_device, photoalbum):
|
2020-04-29 21:23:22 +00:00
|
|
|
photo = photoalbum.photo("photo1")
|
2018-09-08 15:25:16 +00:00
|
|
|
new_item = photo.sync(PHOTO_QUALITY_MEDIUM, client=clear_sync_device)
|
|
|
|
photo._server.refreshSync()
|
2020-04-29 21:23:22 +00:00
|
|
|
item = utils.wait_until(
|
|
|
|
get_sync_item_from_server,
|
|
|
|
delay=0.5,
|
|
|
|
timeout=3,
|
2020-12-07 01:21:47 +00:00
|
|
|
sync_device=clear_sync_device,
|
2020-04-29 21:23:22 +00:00
|
|
|
sync_item=new_item,
|
|
|
|
)
|
|
|
|
media_list = utils.wait_until(
|
|
|
|
get_media, delay=0.25, timeout=3, item=item, server=photo._server
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
assert 1 == len(media_list)
|
|
|
|
assert photo.ratingKey == media_list[0].ratingKey
|
|
|
|
|
|
|
|
|
|
|
|
def test_sync_entire_library_movies(clear_sync_device, movies):
|
|
|
|
new_item = movies.sync(VIDEO_QUALITY_3_MBPS_720p, client=clear_sync_device)
|
|
|
|
movies._server.refreshSync()
|
2020-04-29 21:23:22 +00:00
|
|
|
item = utils.wait_until(
|
|
|
|
get_sync_item_from_server,
|
|
|
|
delay=0.5,
|
|
|
|
timeout=3,
|
2020-12-07 01:21:47 +00:00
|
|
|
sync_device=clear_sync_device,
|
2020-04-29 21:23:22 +00:00
|
|
|
sync_item=new_item,
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
section_content = movies.all()
|
2020-04-29 21:23:22 +00:00
|
|
|
media_list = utils.wait_until(
|
|
|
|
get_media, delay=0.25, timeout=3, item=item, server=movies._server
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
assert len(section_content) == len(media_list)
|
|
|
|
assert [e.ratingKey for e in section_content] == [m.ratingKey for m in media_list]
|
|
|
|
|
|
|
|
|
|
|
|
def test_sync_entire_library_tvshows(clear_sync_device, tvshows):
|
|
|
|
new_item = tvshows.sync(VIDEO_QUALITY_3_MBPS_720p, client=clear_sync_device)
|
|
|
|
tvshows._server.refreshSync()
|
2020-04-29 21:23:22 +00:00
|
|
|
item = utils.wait_until(
|
|
|
|
get_sync_item_from_server,
|
|
|
|
delay=0.5,
|
|
|
|
timeout=3,
|
2020-12-07 01:21:47 +00:00
|
|
|
sync_device=clear_sync_device,
|
2020-04-29 21:23:22 +00:00
|
|
|
sync_item=new_item,
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
section_content = tvshows.searchEpisodes()
|
2020-04-29 21:23:22 +00:00
|
|
|
media_list = utils.wait_until(
|
|
|
|
get_media, delay=0.25, timeout=3, item=item, server=tvshows._server
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
assert len(section_content) == len(media_list)
|
|
|
|
assert [e.ratingKey for e in section_content] == [m.ratingKey for m in media_list]
|
|
|
|
|
|
|
|
|
|
|
|
def test_sync_entire_library_music(clear_sync_device, music):
|
|
|
|
new_item = music.sync(AUDIO_BITRATE_192_KBPS, client=clear_sync_device)
|
|
|
|
music._server.refreshSync()
|
2020-04-29 21:23:22 +00:00
|
|
|
item = utils.wait_until(
|
|
|
|
get_sync_item_from_server,
|
|
|
|
delay=0.5,
|
|
|
|
timeout=3,
|
2020-12-07 01:21:47 +00:00
|
|
|
sync_device=clear_sync_device,
|
2020-04-29 21:23:22 +00:00
|
|
|
sync_item=new_item,
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
section_content = music.searchTracks()
|
2020-04-29 21:23:22 +00:00
|
|
|
media_list = utils.wait_until(
|
|
|
|
get_media, delay=0.25, timeout=3, item=item, server=music._server
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
assert len(section_content) == len(media_list)
|
|
|
|
assert [e.ratingKey for e in section_content] == [m.ratingKey for m in media_list]
|
|
|
|
|
|
|
|
|
|
|
|
def test_sync_entire_library_photos(clear_sync_device, photos):
|
|
|
|
new_item = photos.sync(PHOTO_QUALITY_MEDIUM, client=clear_sync_device)
|
|
|
|
photos._server.refreshSync()
|
2020-04-29 21:23:22 +00:00
|
|
|
item = utils.wait_until(
|
|
|
|
get_sync_item_from_server,
|
|
|
|
delay=0.5,
|
|
|
|
timeout=3,
|
2020-12-07 01:21:47 +00:00
|
|
|
sync_device=clear_sync_device,
|
2020-04-29 21:23:22 +00:00
|
|
|
sync_item=new_item,
|
|
|
|
)
|
2022-02-27 03:26:08 +00:00
|
|
|
# It's not that easy, to just get all the photos within the library, so let's query for photos with device!=0x0
|
2021-03-22 20:14:22 +00:00
|
|
|
section_content = photos.search(libtype="photo", **{"addedAt>>": "2000-01-01"})
|
2020-04-29 21:23:22 +00:00
|
|
|
media_list = utils.wait_until(
|
|
|
|
get_media, delay=0.25, timeout=3, item=item, server=photos._server
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
assert len(section_content) == len(media_list)
|
|
|
|
assert [e.ratingKey for e in section_content] == [m.ratingKey for m in media_list]
|
|
|
|
|
|
|
|
|
|
|
|
def test_playlist_movie_sync(plex, clear_sync_device, movies):
|
|
|
|
items = movies.all()
|
2021-06-06 21:19:57 +00:00
|
|
|
playlist = plex.createPlaylist("Sync: Movies", items=items)
|
2020-04-29 21:23:22 +00:00
|
|
|
new_item = playlist.sync(
|
|
|
|
videoQuality=VIDEO_QUALITY_3_MBPS_720p, client=clear_sync_device
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
playlist._server.refreshSync()
|
2020-04-29 21:23:22 +00:00
|
|
|
item = utils.wait_until(
|
|
|
|
get_sync_item_from_server,
|
|
|
|
delay=0.5,
|
|
|
|
timeout=3,
|
2020-12-07 01:21:47 +00:00
|
|
|
sync_device=clear_sync_device,
|
2020-04-29 21:23:22 +00:00
|
|
|
sync_item=new_item,
|
|
|
|
)
|
|
|
|
media_list = utils.wait_until(
|
|
|
|
get_media, delay=0.25, timeout=3, item=item, server=playlist._server
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
assert len(items) == len(media_list)
|
|
|
|
assert [e.ratingKey for e in items] == [m.ratingKey for m in media_list]
|
|
|
|
playlist.delete()
|
|
|
|
|
|
|
|
|
|
|
|
def test_playlist_tvshow_sync(plex, clear_sync_device, show):
|
|
|
|
items = show.episodes()
|
2021-06-06 21:19:57 +00:00
|
|
|
playlist = plex.createPlaylist("Sync: TV Show", items=items)
|
2020-04-29 21:23:22 +00:00
|
|
|
new_item = playlist.sync(
|
|
|
|
videoQuality=VIDEO_QUALITY_3_MBPS_720p, client=clear_sync_device
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
playlist._server.refreshSync()
|
2020-04-29 21:23:22 +00:00
|
|
|
item = utils.wait_until(
|
|
|
|
get_sync_item_from_server,
|
|
|
|
delay=0.5,
|
|
|
|
timeout=3,
|
2020-12-07 01:21:47 +00:00
|
|
|
sync_device=clear_sync_device,
|
2020-04-29 21:23:22 +00:00
|
|
|
sync_item=new_item,
|
|
|
|
)
|
|
|
|
media_list = utils.wait_until(
|
|
|
|
get_media, delay=0.25, timeout=3, item=item, server=playlist._server
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
assert len(items) == len(media_list)
|
|
|
|
assert [e.ratingKey for e in items] == [m.ratingKey for m in media_list]
|
|
|
|
playlist.delete()
|
|
|
|
|
|
|
|
|
|
|
|
def test_playlist_mixed_sync(plex, clear_sync_device, movie, episode):
|
|
|
|
items = [movie, episode]
|
2021-06-06 21:19:57 +00:00
|
|
|
playlist = plex.createPlaylist("Sync: Mixed", items=items)
|
2020-04-29 21:23:22 +00:00
|
|
|
new_item = playlist.sync(
|
|
|
|
videoQuality=VIDEO_QUALITY_3_MBPS_720p, client=clear_sync_device
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
playlist._server.refreshSync()
|
2020-04-29 21:23:22 +00:00
|
|
|
item = utils.wait_until(
|
|
|
|
get_sync_item_from_server,
|
|
|
|
delay=0.5,
|
|
|
|
timeout=3,
|
2020-12-07 01:21:47 +00:00
|
|
|
sync_device=clear_sync_device,
|
2020-04-29 21:23:22 +00:00
|
|
|
sync_item=new_item,
|
|
|
|
)
|
|
|
|
media_list = utils.wait_until(
|
|
|
|
get_media, delay=0.25, timeout=3, item=item, server=playlist._server
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
assert len(items) == len(media_list)
|
|
|
|
assert [e.ratingKey for e in items] == [m.ratingKey for m in media_list]
|
|
|
|
playlist.delete()
|
|
|
|
|
|
|
|
|
|
|
|
def test_playlist_music_sync(plex, clear_sync_device, artist):
|
|
|
|
items = artist.tracks()
|
2021-06-06 21:19:57 +00:00
|
|
|
playlist = plex.createPlaylist("Sync: Music", items=items)
|
2020-04-29 21:23:22 +00:00
|
|
|
new_item = playlist.sync(
|
|
|
|
audioBitrate=AUDIO_BITRATE_192_KBPS, client=clear_sync_device
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
playlist._server.refreshSync()
|
2020-04-29 21:23:22 +00:00
|
|
|
item = utils.wait_until(
|
|
|
|
get_sync_item_from_server,
|
|
|
|
delay=0.5,
|
|
|
|
timeout=3,
|
2020-12-07 01:21:47 +00:00
|
|
|
sync_device=clear_sync_device,
|
2020-04-29 21:23:22 +00:00
|
|
|
sync_item=new_item,
|
|
|
|
)
|
|
|
|
media_list = utils.wait_until(
|
|
|
|
get_media, delay=0.25, timeout=3, item=item, server=playlist._server
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
assert len(items) == len(media_list)
|
|
|
|
assert [e.ratingKey for e in items] == [m.ratingKey for m in media_list]
|
|
|
|
playlist.delete()
|
|
|
|
|
|
|
|
|
2018-09-14 18:03:23 +00:00
|
|
|
def test_playlist_photos_sync(plex, clear_sync_device, photoalbum):
|
|
|
|
items = photoalbum.photos()
|
2021-06-06 21:19:57 +00:00
|
|
|
playlist = plex.createPlaylist("Sync: Photos", items=items)
|
2020-04-29 21:23:22 +00:00
|
|
|
new_item = playlist.sync(
|
|
|
|
photoResolution=PHOTO_QUALITY_MEDIUM, client=clear_sync_device
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
playlist._server.refreshSync()
|
2020-04-29 21:23:22 +00:00
|
|
|
item = utils.wait_until(
|
|
|
|
get_sync_item_from_server,
|
|
|
|
delay=0.5,
|
|
|
|
timeout=3,
|
2020-12-07 01:21:47 +00:00
|
|
|
sync_device=clear_sync_device,
|
2020-04-29 21:23:22 +00:00
|
|
|
sync_item=new_item,
|
|
|
|
)
|
|
|
|
media_list = utils.wait_until(
|
|
|
|
get_media, delay=0.25, timeout=3, item=item, server=playlist._server
|
|
|
|
)
|
2018-09-08 15:25:16 +00:00
|
|
|
assert len(items) == len(media_list)
|
|
|
|
assert [e.ratingKey for e in items] == [m.ratingKey for m in media_list]
|
|
|
|
playlist.delete()
|
2021-05-29 23:52:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_collection_sync(plex, clear_sync_device, movies, movie):
|
|
|
|
items = [movie]
|
2021-06-06 21:19:57 +00:00
|
|
|
collection = plex.createCollection("Sync: Collection", section=movies, items=items)
|
2021-05-29 23:52:11 +00:00
|
|
|
new_item = collection.sync(
|
|
|
|
videoQuality=VIDEO_QUALITY_3_MBPS_720p, client=clear_sync_device
|
|
|
|
)
|
|
|
|
collection._server.refreshSync()
|
|
|
|
item = utils.wait_until(
|
|
|
|
get_sync_item_from_server,
|
|
|
|
delay=0.5,
|
|
|
|
timeout=3,
|
|
|
|
sync_device=clear_sync_device,
|
|
|
|
sync_item=new_item,
|
|
|
|
)
|
|
|
|
media_list = utils.wait_until(
|
|
|
|
get_media, delay=0.25, timeout=3, item=item, server=collection._server
|
|
|
|
)
|
|
|
|
assert len(items) == len(media_list)
|
|
|
|
assert [e.ratingKey for e in items] == [m.ratingKey for m in media_list]
|
|
|
|
collection.delete()
|