def play_all(self): Command(Audio_Comm['PLAY_ALL']).start() time.sleep(3) status = checkfile.check_stauts('text="00:03/01:00"') if status == True: logger.info('Play audio is success') else: logger.error('Play audio is failed')
def seek_player_mid(self): Command(Audio_Comm['SEEK_MID']).start() time.sleep(3) status = checkfile.check_stauts('text="00:34/01:00"') if status == True: logger.info('Seek the audio to middle is success') else: logger.error('Seek the audio to middle is failed') exit(1)
def get_movie_changes(self, end_date, start_date): uri = self.api_url + "movie/changes" querystring = {"api_key": BaseConfig.TOKEN_V3, "end_date": end_date, "start_date": start_date, "page": 1} try: _response = requests.get(url=uri, params=querystring) try: body = json.loads(_response.text) except JSONDecodeError as e: logger.error(f"Failed to parse response json: {e}") if _response.text is not None: body = _response.text else: body = _response.reason logger.info(RESPONSE_TEXT.format(body)) return body, _response except Exception as e: logger.error(F"{e.__class__.__name__} get_movie_by_id failed with error: {e}") raise e
def get_most_popular_movies(self, page=1): uri = self.api_url + "movie/popular" querystring = {"api_key": BaseConfig.TOKEN_V3, "language": "en-US", "page": page} try: _response = requests.get(url=uri, params=querystring) try: body = json.loads(_response.text) except JSONDecodeError as e: logger.error(f"Failed to parse response json: {e}") if _response.text is not None: body = _response.text else: body = _response.reason logger.info(RESPONSE_TEXT.format(body)) return body, _response except Exception as e: logger.error(F"{e.__class__.__name__} get_most_popular_movies failed with error: {e}") raise e
def get_posts(self): uri = self.api_url + "posts" try: _response = requests.get(url=uri, headers=self.headers) try: body = json.loads(_response.text) except JSONDecodeError as e: logger.error(f"Failed to parse response json: {e}") if _response.text is not None: body = _response.text else: body = _response.reason logger.info(RESPONSE_TEXT.format(body)) return body, _response except Exception as e: logger.error( F"{e.__class__.__name__} get_posts failed with error: {e}") raise e
def update_post(self, title, body, id_, user_id): uri = self.api_url + "posts" + "/" + str(user_id) payload = RequestBody().update_post(title, body, user_id, id_) try: logger.info(F"API Service URL is POST - {uri}") _response = requests.put(uri, data=payload, headers=self.headers) try: body = json.loads(_response.text) except JSONDecodeError as e: logger.error(f"Failed to parse response json: {e}") if _response.text is not None: body = _response.text else: body = _response.reason logger.info(RESPONSE_TEXT.format(body)) return body, _response except Exception as e: logger.error( F"{e.__class__.__name__} update_post failed with error: {e}") raise e