def set_is_playing(self, info, is_playing): """ Mark the given ItemInfo as playing, based on the is_playing bool. Should also send a 'changed' message, if the is_playing state changed. """ if info.is_playing != is_playing: # modifying the ItemInfo in-place messes up the Tracker's # object-changed logic, so make a copy info_cache = app.device_manager.info_cache[info.device_info.mount] info = info_cache[info.id] = messages.ItemInfo( info.id, **info.__dict__) database = info.device_info.database info.is_playing = is_playing database[info.file_type][info.id][u'is_playing'] = is_playing database.emit('item-changed', info)
def callback(): if not os.path.exists(new_path): return # copy failed, just give up device_item = item.DeviceItem( device=self.device, file_type=item_info.file_type, video_path=new_path[len(self.device.mount):], title=item_info.name, feed_name=item_info.feed_name, feed_url=item_info.feed_url, description=item_info.description, release_date=time.mktime(item_info.release_date.timetuple()), duration=(item_info.duration and item_info.duration * 1000 or None), permalink=item_info.permalink, commentslink=item_info.commentslink, payment_link=item_info.payment_link, screenshot=item_info.thumbnail, thumbnail_url=item_info.thumbnail_url, file_format=item_info.file_format, license=item_info.license, url=item_info.file_url, media_type_checked=item_info.media_type_checked, mime_type=item_info.mime_type, creation_time=time.mktime(item_info.date_added.timetuple()), title_tag=item_info.title_tag, artist=item_info.artist, album=item_info.album, track=item_info.track, year=item_info.year, genre=item_info.genre, metadata_version=item_info.metadata_version, mdp_state=item_info.mdp_state, auto_sync=getattr(item_info, 'auto_sync', False) ) device_item._migrate_thumbnail() database = self.device.database database.setdefault(device_item.file_type, {}) database[device_item.file_type][device_item.id] = \ device_item.to_dict() database.emit('item-added', device_item) self.device.remaining -= device_item.size