Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _video_playback(plex, client):
try:
mtype = 'video'
movie = plex.library.section(CONFIG.movie_section).get(CONFIG.movie_title)
subs = [s for s in movie.subtitleStreams if s.language == 'English']
log(2, 'Client: %s (%s)' % (client.title, client.product))
log(2, 'Capabilities: %s' % client.protocolCapabilities)
log(2, 'Playing to %s..' % movie.title)
client.playMedia(movie); time.sleep(5)
log(2, 'Pause..')
client.pause(mtype); time.sleep(2)
log(2, 'Step Forward..')
client.stepForward(mtype); time.sleep(5)
log(2, 'Play..')
client.play(mtype); time.sleep(3)
log(2, 'Seek to 10m..')
client.seekTo(10*60*1000); time.sleep(5)
log(2, 'Disable Subtitles..')
client.setSubtitleStream(0, mtype); time.sleep(10)
log(2, 'Load English Subtitles %s..' % subs[0].id)
def _navigate(plex, client):
episode = plex.library.section(CONFIG.show_section).get(CONFIG.show_title).get(CONFIG.show_episode)
artist = plex.library.section(CONFIG.audio_section).get(CONFIG.audio_artist)
log(2, 'Client: %s (%s)' % (client.title, client.product))
log(2, 'Capabilities: %s' % client.protocolCapabilities)
# Move around a bit
log(2, 'Browsing around..')
client.moveDown(); time.sleep(0.5)
client.moveDown(); time.sleep(0.5)
client.moveDown(); time.sleep(0.5)
client.select(); time.sleep(3)
client.moveRight(); time.sleep(0.5)
client.moveRight(); time.sleep(0.5)
client.moveLeft(); time.sleep(0.5)
client.select(); time.sleep(3)
client.goBack(); time.sleep(1)
client.goBack(); time.sleep(3)
# Go directly to media
def test_search_show(account, plex):
result_server = plex.search(CONFIG.show_title)
result_shows = plex.library.section(CONFIG.show_section).search(CONFIG.show_title)
result_movies = plex.library.section(CONFIG.movie_section).search(CONFIG.show_title)
log(2, 'Searching for: %s' % CONFIG.show_title)
log(4, 'Result Server: %s' % result_server)
log(4, 'Result Shows: %s' % result_shows)
log(4, 'Result Movies: %s' % result_movies)
assert result_server, 'Show not found.'
assert result_server == result_shows, 'Show searches not consistent.'
assert not result_movies, 'Movie search returned show title.'
def test_search_audio(account, plex):
result_server = plex.search(CONFIG.audio_artist)
result_library = plex.library.search(CONFIG.audio_artist)
result_music = plex.library.section(CONFIG.audio_section).search(CONFIG.audio_artist)
log(2, 'Searching for: %s' % CONFIG.audio_artist)
log(4, 'Result Server: %s' % result_server)
log(4, 'Result Library: %s' % result_library)
log(4, 'Result Music: %s' % result_music)
assert result_server, 'Artist not found.'
assert result_server == result_library == result_music, 'Audio searches not consistent.'
def test_partial_video(account, plex):
result = plex.search(CONFIG.movie_foreign)
log(2, 'Title: %s' % result[0].title)
log(2, 'Original Title: %s' % result[0].originalTitle)
assert(result[0].originalTitle != None)
def test_client_navigation(account, plex):
client = getclient(CONFIG.client, CONFIG.client_baseurl, plex)
_navigate(plex, client)
def _signin(self, username, password, timeout):
if self._token:
return self.query(self.key), self.key
username = username or CONFIG.get('auth.myplex_username')
password = password or CONFIG.get('auth.myplex_password')
data = self.query(self.SIGNIN, method=self._session.post, auth=(username, password), timeout=timeout)
return data, self.SIGNIN