This vedio shows how to use pytube and PySide to download YouTube audio (mp3).

The content includes:

  1. PySide Introduction

  2. Filter Audio Stream

  3. Download and rename Youtube mp3 file

本視頻說明如何使用pytube與PyQt下載YouTube影片。

內容包含:

  1. PySide簡介

  2. 篩選聲音資料流

  3. 下載和重新命名YouTube MP3檔

Pyside template

1
2
3
4
5
6
7
8
9
10
11
import sys

from PySide6 import QtWidgets

from PySide6.QtCore import QFile, QIODevice

from PySide6.QtUiTools import QUiLoader

class MainWindow(QtWidgets.QMainWindow):

def __init__(self, ui_file_name, *args, **kwargs):

access methods of the base class

super(MainWindow, self).__init__(*args, **kwargs)

Load the UI Page by PySide6

loader = QUiLoader()

file = QFile(ui_file_name)

file.open(QIODevice.ReadOnly)

self.ui = loader.load(file)

file.close()

self.ui.setWindowTitle(“ui title”)

self.ui.show()

1
2
3
4
5
6
7
def main():

app = QtWidgets.QApplication(sys.argv)

ui_file_name = "ui_file.ui"

main = MainWindow(ui_file_name)

sys.exit(app.exec())

if __name__ == ‘__main__‘:

main()