def decrease_watch_prio(self, video): self.logger.info("Decreasing watch prio for: {}".format( video.__dict__)) video.watch_prio += 1 UpdateVideo(video, update_existing=True, finished_listeners=[self.downloadedVideosChangedinDB ]).start()
def tile_discarded(self, video: Video): self.model.hide_video_item(video) self.logger.info( "Video hidden from grid view(Discarded): {} - {} [{}]".format( video.channel_title, video.title, video.url_video)) self.hiddenVideosChanged.emit() self.downloadedVideosChanged.emit() UpdateVideo(video, update_existing=True).start()
def download_finished(self, video: VideoD): """ Action to take when download has finished. :param video: :return: """ self.redraw_video(video) # Update Video in Database with the changed attributes UpdateVideo(video, update_existing=True, finished_listeners=[self.downloadedVideosChangedinDB ]).start()
def mouseReleaseEvent(self, ev): print('clicked {:2d}: {} {} - {}'.format(self.img_id, self.video.url_video, self.video.channel_title, self.video.title)) self.clipboard.setText(self.video.url_video) self.video.downloaded = True UpdateVideo(self.video, update_existing=True).start() self.status_bar.showMessage( 'Copied URL to clipboard: {} ({} - {})'.format( self.video.url_video, self.video.channel_title, self.video.title))
def increase_watch_prio(self, video): """ Increases the priority of a video, which will put it further up the list in a sort. :param video: :return: """ self.logger.info("Increasing watch prio for: {}".format( video.__dict__)) video.watch_prio -= 1 # Update Video in Database with the changed attributes UpdateVideo(video, update_existing=True, finished_listeners=[self.downloadedVideosChangedinDB ]).start()
def download_video(video, db_update_listeners=None, youtube_dl_finished_listener=None): use_youtube_dl = read_config('Youtube-dl', 'use_youtube_dl') video.downloaded = True video.date_downloaded = datetime.datetime.utcnow() UpdateVideo(video, update_existing=True, finished_listeners=db_update_listeners).start() if use_youtube_dl: download_progress_signal = DownloadViewListener.download_using_youtube_dl( video, youtube_dl_finished_listener) DownloadViewListener.static_self.newYTDLDownload.emit( download_progress_signal)
def update_and_redraw_tiles(self, video): """ Common operations for tiles. :param video: :return: """ # Update a Grid View self.videos_changed() # Update Video in Database with the changed attributes UpdateVideo(video, update_existing=True).start() if read_config('GridView', 'show_dismissed'): # Update a GridView from database. self.update_from_db() # Redraw the video self.redraw_videos(video)
def new_file(self, vid_id, vid_path): vid = db_session.query(Video).get(vid_id) if vid: if not vid.downloaded: vid.vid_path = vid_path vid.date_downloaded = datetime.datetime.utcnow() vid.downloaded = True thumb_path = os.path.join(THUMBNAILS_PATH, '{}.jpg'.format(vid.video_id)) downloaded_thumbnail = os.path.isfile(thumb_path) if downloaded_thumbnail and (not vid.thumbnail_path): vid.thumbnail_path = thumb_path self.logger.warning( "Thumbnail downloaded, but path didn't exist in db, for video: {}" .format(vid.__dict__)) elif (not vid.thumbnail_path) or (not downloaded_thumbnail): if not downloaded_thumbnail: self.logger.warning( "Thumbnail path in db, but not on disk, for video: {}" .format(vid.__dict__)) self.logger.info("Downloading thumbnail for: {}".format( vid.__dict__)) download_thumbnails_threaded([vid]) self.logger.info( "Updating existing record in db: {} - {}".format( vid.title, vid.__dict__)) db_session.commit() self.model.update_subfeed_videos_from_db() self.model.update_playback_videos_from_db() else: self.logger.info( "File already downloaded by this system: {} - {}".format( vid.title, vid.__dict__)) db_session.remove() else: db_session.remove() youtube_keys = load_keys(1) self.logger.info( "Grabbing new video information from youtube: {}".format( vid_id)) response_videos = list_uploaded_videos_videos( youtube_keys[0], [vid_id], 1) if len(response_videos) > 0: video = response_videos[0] video.vid_path = vid_path video.downloaded = True video.watched = False video.date_downloaded = datetime.datetime.utcnow() self.logger.info("Downloading thumbnail: {} - {}".format( video.title, video.__dict__)) download_thumbnails_threaded([video]) self.logger.info("Adding new file to db: {} - {}".format( video.title, video.__dict__)) UpdateVideo(video, finished_listeners=[ self.model.playback_grid_view_listener. downloadedVideosChangedinDB ]).start() else: self.logger.warning( "Video with id {}, not found on youtube servers".format( vid_id))
def tile_watched(self, video: Video): self.logger.info("Mark watched: {} - {}".format( video.title, video.__dict__)) self.model.hide_downloaded_video_item(video) self.downloadedVideosChanged.emit() UpdateVideo(video, update_existing=True).start()
def download_finished(self, video: VideoD): self.redrawVideos.emit([video]) UpdateVideo(video, update_existing=True, finished_listeners=[self.downloadedVideosChangedinDB ]).start()