Exemple #1
0
 def current_movie_time(self):
     logger.info('Getting current movie time')
     # TODO: Fix 'self.resource.timeline.time' can be None sometimes if the movie was paused. Find solution.
     print(self.resource.timeline.time)
     import math
     timestamp = math.floor(self.resource.timeline.time / 1000)
     hours = math.floor(timestamp/3600)
     min = math.floor(timestamp / 60) - hours * 60
     secs = timestamp - hours*3600 - min*60
     current_time = f"{hours}:{min:02}:{secs:02}"
     return current_time
Exemple #2
0
    def seek_to(self, hour, minute, second):
        logger.info(f"Seeking to: '{hour}:{minute}:{second}")

        def seconds(seconds_num):
            return seconds_num * 1000

        def minutes(minutes_num):
            return seconds(minutes_num * 60)

        def hours(hours_num):
            return minutes(hours_num * 60)

        self.resource.seekTo(
            hours(hour) + minutes(minute) + seconds(second)
        )
Exemple #3
0
 def _connect_to_resource(self):
     self.account = MyPlexAccount(self.username, self.password)
     if (self.resource_name):
         self.resource = self.account.resource(self.resource_name).connect()
     else:
         logger.info("DEBUG TEMP: Add resource to envvar")
Exemple #4
0
 def play(self):
     logger.info('Playing')
     self.resource.play()
Exemple #5
0
 def _on_message(self, _client, _userdata, raw_msg):
     msg = json.loads(raw_msg.payload.decode())
     logger.info(f"Just received: '{msg}'")
     for listener in self.msg_listeners:
         if msg['type'] == listener.msg_type:
             listener.on_message_callback(msg)
Exemple #6
0
 def _on_connect(self, client, _userdata, _flags, _rc):
     logger.info('Connected to MQTT')
     client.subscribe(self.topic)
     logger.info(f"Subscribed to {self.topic}")
Exemple #7
0
 def destroy(self):
     logger.info('Disconnecting from MQTT')
     self.paho_client.loop_stop()
     self.paho_client.disconnect()
Exemple #8
0
 def connect(self):
     logger.info('Connecting to MQTT')
     self.paho_client.connect(host=config['mqtt']['domain'],
                              port=config['mqtt']['port'])
     self.paho_client.loop_start()