def delete_video_from_playlist(self): if len(self.playlistVideoIds) > 0: # buttons' names end in a number from 0 to 5 then we can use that number as an index for array senderId = self.sender().objectName()[-1:] YouTubeProvider.delete_from_playlist(self.playlistVideoIds[int(senderId)]) self.load_playlist()
def add_video_to_playlist(self): if len(self.videoIds) > 0: # buttons' names end in a number from 0 to 5 then we can use that number as an index for array senderId = self.sender().objectName()[-1:] videoId = self.videoIds[int(senderId)] playlistId = self.playlistIds[self.currentPlaylistRow] YouTubeProvider.add_to_playlist(videoId, playlistId)
def create_playlist(self): if YouTubeProvider.login is not None: name, ok = QInputDialog.getText(self, 'Add playlist', 'Enter playlist name: ') if ok: YouTubeProvider.create_playlist(name) self.userPlaylistsList0.addItem(name) self.userPlaylistsList1.addItem(name) else: self.message = QMessageBox() self.message.setWindowTitle("Error") self.message.setText("You must log in first.") self.message.setDefaultButton(QMessageBox.Ok) self.message.open()
def delete_playlist(self): if self.userPlaylistsList0.item(self.currentPlaylistRow) is not None: reply = QMessageBox.question(self, 'Are you sure?', "Are you sure?", QMessageBox.Yes, QMessageBox.No, QMessageBox.No ) if reply == QMessageBox.Yes: YouTubeProvider.delete_playlist(self.playlistIds[self.currentPlaylistRow]) self.userPlaylistsList0.takeItem(self.currentPlaylistRow) self.userPlaylistsList1.takeItem(self.currentPlaylistRow) else: self.message = QMessageBox() self.message.setWindowTitle("Error") self.message.setText("You must log in first or you have no playlists.") self.message.setDefaultButton(QMessageBox.Ok) self.message.open()
def list_playlists(self): self.userPlaylistsList0.clear() self.userPlaylistsList1.clear() titles, self.playlistIds = YouTubeProvider.get_user_playlists() for title in titles: self.userPlaylistsList0.addItem(title) self.userPlaylistsList1.addItem(title)
def search(self): if self.animeListWidget.item(self.currentAnimeRow) is not None: if YouTubeProvider.login is not None: self.videoTitles, self.videoThumbnails, self.videoIds, self.videoUrlIds = YouTubeProvider.youtube_search( self.animeListWidget.item(self.currentAnimeRow).text(), self.addTextLabel.text() ) self.count_pages(self.videoTitles, "anime") self.fill_thumbnails(self.videoThumbnails, "anime") self.fill_labels(self.videoTitles, "anime") self.update_page_label("anime") self.statusBar().showMessage('Search done!') else: self.message = QMessageBox() self.message.setWindowTitle("Error") self.message.setText("You must log in first.") self.message.setDefaultButton(QMessageBox.Ok) self.message.open() else: self.message = QMessageBox() self.message.setWindowTitle("Error") self.message.setText("You must choose anime title first.") self.message.setDefaultButton(QMessageBox.Ok) self.message.open()
def load_playlist(self): if len(self.playlistIds) > 0: self.playlistVideoTitles, self.playlistVideoThumbnails, self.playlistVideoIds, self.playlistVideoUrlIds = YouTubeProvider.load_playlist( self.playlistIds[self.currentPlaylistRow] ) self.count_pages(self.playlistVideoTitles, "playlist") self.fill_thumbnails(self.playlistVideoThumbnails, "playlist") self.fill_labels(self.playlistVideoTitles, "playlist") self.update_page_label("playlist") self.statusBar().showMessage('Playlist loaded!') else: self.message = QMessageBox() self.message.setWindowTitle("Error") self.message.setText("You must log in first or this playlist has no videos.") self.message.setDefaultButton(QMessageBox.Ok) self.message.open()