diff --git a/jellyplayer/__init__.py b/jellyplayer/__init__.py index 73555a5..63e50ba 100644 --- a/jellyplayer/__init__.py +++ b/jellyplayer/__init__.py @@ -1,20 +1,33 @@ __version__ = '0.1.0' -import sys,os,subprocess +import sys,os,subprocess,platform +from signal import SIGTERM, signal from PySide6.QtWidgets import QApplication, QMainWindow, QWidget -from PySide6.QtCore import QUrl, Slot, QObject, QProcess, Qt, QCoreApplication -from PySide6.QtGui import QIcon, QPixmap +from PySide6.QtCore import QUrl, Slot, QObject, QProcess, Qt, QCoreApplication, Signal, QSize +from PySide6.QtGui import QIcon, QPixmap, QOpenGLContext from PySide6.QtWebChannel import QWebChannel -from PySide6.QtQml import QQmlApplicationEngine +from PySide6.QtWebEngineWidgets import QWebEngineView +from PySide6.QtWebEngineCore import QWebEngineSettings +from PySide6.QtWebEngineQuick import QtWebEngineQuick +from PySide6.QtQuick import QQuickFramebufferObject, QQuickView, QQuickItem +from PySide6.QtOpenGL import QOpenGLFramebufferObject +from PySide6.QtOpenGLWidgets import QOpenGLWidget +from PySide6.QtQml import QQmlApplicationEngine, QQmlComponent,qmlRegisterType +from ctypes import windll, cast, c_void_p + +# if (platform.system() == "Windows"): +# from OpenGL import GL, WGL +# else: +# from OpenGL import GL, GLX + os.environ["PATH"] = os.path.dirname(__file__) + os.pathsep + os.environ["PATH"] -import mpv +from mpv import MPV, MpvRenderContext, MpvGlGetProcAddressFn QCoreApplication.setAttribute(Qt.AA_ShareOpenGLContexts) app = QApplication(["--enable-smooth-scrolling", "--enable-gpu"]) print(os.path.dirname(__file__) + os.pathsep) try: - from ctypes import windll myappid = 'prayag17.jellyplayer.0.1.0' windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid) except ImportError: @@ -28,51 +41,54 @@ class Backend(QObject): def restart(self): QApplication.quit() status = QProcess.startDetached(sys.executable, sys.argv) - - @Slot(str) - def launchPlayer(self, videoUrl): - import locale - locale.setlocale(locale.LC_NUMERIC, 'C') - playerwindow = PlayerWindow(videoUrl) - window.hide() - playerwindow.showMaximized() -class MainWin(): +class MainWin(QMainWindow): def __init__(self): - super().__init__(); + super().__init__() self.dirRaw = os.path.dirname(os.path.realpath(__file__)) self.dir = self.dirRaw.replace("\\","/") - self.view= QQmlApplicationEngine() + self.view= QWebEngineView() + self.view.load(QUrl("http://localhost:2703")) + self.setCentralWidget(self.view) + self.setWindowIcon(QIcon(QPixmap(f"{self.dir}/assets/icon.png"))) - app.setWindowIcon(QIcon(QPixmap(f"{self.dir}/assets/icon.png"))) - self.view.load(QUrl.fromLocalFile(f"{self.dir}/mainWindow.qml")) + self.view.settings().setAttribute(QWebEngineSettings.JavascriptEnabled, True) + self.view.settings().setAttribute(QWebEngineSettings.PluginsEnabled, True) + self.view.settings().setAttribute(QWebEngineSettings.LocalContentCanAccessRemoteUrls, True) + self.view.settings().setAttribute(QWebEngineSettings.LocalStorageEnabled, True) + self.view.settings().setAttribute(QWebEngineSettings.LocalContentCanAccessFileUrls, True) + self.view.settings().setAttribute(QWebEngineSettings.ScrollAnimatorEnabled, True) + + self.view.loadFinished.connect(self.handleLoaded) + + self.inspector = QWebEngineView() + self.inspector.setWindowTitle("Inspector") self.backend = Backend() self.channel = QWebChannel() self.channel.registerObject('backend', self.backend) + def handleLoaded(self, ok): + if ok: + self.view.page().setDevToolsPage(self.inspector.page()) + self.inspector.show() + def createPlayer(self, videoUrl): self.container = QWidget(self) self.setCentralWidget(self.container) self.container.setAttribute(Qt.WA_DontCreateNativeAncestors) self.container.setAttribute(Qt.WA_NativeWindow) - player = mpv.MPV(wid=str(int(self.container.winId())), + player = MPV(wid=str(int(self.container.winId())), gpu_context="d3d11", hwdec="nvdec", log_handler=print, loglevel='debug') player.play(videoUrl) -class PlayerWindow(QMainWindow): - def __init__(self,videoUrl): - super().__init__() - - -frontendProcess = subprocess.Popen(f'{sys.executable} {os.path.dirname(__file__)}/jellyplayer-jellyfin-vue/frontend/dist/server.py', shell=True) +frontend= subprocess.Popen(f"python {os.path.dirname(os.path.realpath(__file__))}/jellyplayer-jellyfin-vue/frontend/dist/server.py", shell=True) window = MainWin() - -print(window.dir) +window.showMaximized() exitApp = app.exec() -os.kill(frontendProcess.pid, 0) +frontend.kill() sys.exit(exitApp) \ No newline at end of file diff --git a/jellyplayer/jellyplayer-jellyfin-vue b/jellyplayer/jellyplayer-jellyfin-vue index 0b9c08f..c65568b 160000 --- a/jellyplayer/jellyplayer-jellyfin-vue +++ b/jellyplayer/jellyplayer-jellyfin-vue @@ -1 +1 @@ -Subproject commit 0b9c08f6919a2d39a7e5a1b3e0c5f5eee2e78fe2 +Subproject commit c65568bbeda4233e29666c7b81a5df1efc7a1dfd diff --git a/jellyplayer/mainWindow.qml b/jellyplayer/mainWindow.qml index 77548f6..ef387a9 100644 --- a/jellyplayer/mainWindow.qml +++ b/jellyplayer/mainWindow.qml @@ -1,27 +1,41 @@ import QtWebEngine -// import QtWebEngine.WebEngineSettings import QtWebChannel -import QtQuick.Window +import QtQuick import QtQuick.Controls -Window{ - id: mainWindow - title: "Jellyfin Player" - objectName: "mainWindow" - minimumHeight: 720 - minimumWidth: 1280 - visible: true +import WebView - WebEngineView{ - id:webView - url:"http://127.0.0.1:5000"; +Item{ + id: window + objectName: "window" + // minimumHeight: 720 + // minimumWidth: 1280 + // visible: true + + // QtObject{ + // id:mpvComObj + // WebChannel.id: backend + // function createMpv(url) { + // video.play(url) + // } + // } + + // MpvObject{ + // id:video; + // anchors.fill: parent + // } + + // WebChannel{ + // id: channel + // registeredObjects: [mpvComObj] + // } + + WebView { + id:webView; + visible: true; width: mainWindow.width; height: mainWindow.height; anchors.fill: parent; - settings.localStorageEnabled: true; - settings.localContentCanAccessRemoteUrls: true; - settings.localContentCanAccessFileUrls: true; - settings.javascriptEnabled: true; } - property QtObject webChannel: webView.webChannel + // property QtObject webChannel: webView.webChannel } \ No newline at end of file diff --git a/jellyplayer/main_win.spec b/jellyplayer/main_win.spec index d9efa3d..d84eda4 100644 --- a/jellyplayer/main_win.spec +++ b/jellyplayer/main_win.spec @@ -4,10 +4,10 @@ block_cipher = None -a = Analysis(['main.py'], - pathex=[], +a = Analysis(['__init__.py'], + pathex=['D:\\Jellyfin\\JellyPlayer\\jellyplayer'], binaries=[], - datas=[('JellyPlayer-FrontEnd/frontend/dist', 'mainWindow.qml')], + datas=[('jellyplayer-jellyfin-vue/frontend/dist', 'jellyplayer-jellyfin-vue/frontend/dist'), ('mainWindow.qml', '.')], hiddenimports=[], hookspath=[], hooksconfig={}, @@ -29,7 +29,7 @@ exe = EXE(pyz, bootloader_ignore_signals=False, strip=False, upx=True, - console=False, + console=True, disable_windowed_traceback=False, target_arch=None, codesign_identity=None, @@ -42,4 +42,4 @@ coll = COLLECT(exe, strip=False, upx=True, upx_exclude=[], - name='JellyPlayer') + name='main_win') diff --git a/jellyplayer/tp.html b/jellyplayer/tp.html new file mode 100644 index 0000000..8ba61d7 --- /dev/null +++ b/jellyplayer/tp.html @@ -0,0 +1,15 @@ + + + + + + + + Document + + + +

HEllorn vun

+ + + diff --git a/poetry.lock b/poetry.lock index 88ca2c5..48e7a76 100644 --- a/poetry.lock +++ b/poetry.lock @@ -133,7 +133,7 @@ python-versions = ">=3.7" [[package]] name = "more-itertools" -version = "8.12.0" +version = "8.13.0" description = "More routines for operating on iterables, beyond itertools" category = "dev" optional = false @@ -150,6 +150,14 @@ python-versions = ">=3.6" [package.dependencies] pyparsing = ">=2.0.2,<3.0.5 || >3.0.5" +[[package]] +name = "pastel" +version = "0.2.1" +description = "Bring colors to your terminal." +category = "dev" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" + [[package]] name = "pefile" version = "2021.9.3" @@ -172,6 +180,21 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" [package.extras] dev = ["pre-commit", "tox"] +[[package]] +name = "poethepoet" +version = "0.13.1" +description = "A task runner that works well with poetry." +category = "dev" +optional = false +python-versions = ">=3.6.2" + +[package.dependencies] +pastel = ">=0.2.1,<0.3.0" +tomli = ">=1.2.2" + +[package.extras] +poetry_plugin = ["poetry (>=1.0,<2.0)"] + [[package]] name = "py" version = "1.11.0" @@ -207,9 +230,17 @@ category = "main" optional = false python-versions = ">=3.7" +[[package]] +name = "pyopengl" +version = "3.1.6" +description = "Standard OpenGL bindings for Python" +category = "main" +optional = false +python-versions = "*" + [[package]] name = "pyparsing" -version = "3.0.8" +version = "3.0.9" description = "pyparsing module - Classes and methods to define and execute parsing grammars" category = "dev" optional = false @@ -302,6 +333,14 @@ category = "main" optional = false python-versions = "<3.11,>=3.6" +[[package]] +name = "tomli" +version = "2.0.1" +description = "A lil' TOML parser" +category = "dev" +optional = false +python-versions = ">=3.7" + [[package]] name = "waitress" version = "2.1.1" @@ -347,8 +386,8 @@ testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest- [metadata] lock-version = "1.1" -python-versions = "~3.9" -content-hash = "01d083ecf4c046d564faac5a278a676466c2af454be4303e8408333ab073e5a1" +python-versions = "~3.8" +content-hash = "e833a433cd43e523186875865be62d3a7e7cb88c807d487dcbf778f3494b6c1d" [metadata.files] altgraph = [ @@ -437,13 +476,17 @@ markupsafe = [ {file = "MarkupSafe-2.1.1.tar.gz", hash = "sha256:7f91197cc9e48f989d12e4e6fbc46495c446636dfc81b9ccf50bb0ec74b91d4b"}, ] more-itertools = [ - {file = "more-itertools-8.12.0.tar.gz", hash = "sha256:7dc6ad46f05f545f900dd59e8dfb4e84a4827b97b3cfecb175ea0c7d247f6064"}, - {file = "more_itertools-8.12.0-py3-none-any.whl", hash = "sha256:43e6dd9942dffd72661a2c4ef383ad7da1e6a3e968a927ad7a6083ab410a688b"}, + {file = "more-itertools-8.13.0.tar.gz", hash = "sha256:a42901a0a5b169d925f6f217cd5a190e32ef54360905b9c39ee7db5313bfec0f"}, + {file = "more_itertools-8.13.0-py3-none-any.whl", hash = "sha256:c5122bffc5f104d37c1626b8615b511f3427aa5389b94d61e5ef8236bfbc3ddb"}, ] packaging = [ {file = "packaging-21.3-py3-none-any.whl", hash = "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"}, {file = "packaging-21.3.tar.gz", hash = "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb"}, ] +pastel = [ + {file = "pastel-0.2.1-py2.py3-none-any.whl", hash = "sha256:4349225fcdf6c2bb34d483e523475de5bb04a5c10ef711263452cb37d7dd4364"}, + {file = "pastel-0.2.1.tar.gz", hash = "sha256:e6581ac04e973cac858828c6202c1e1e81fee1dc7de7683f3e1ffe0bfd8a573d"}, +] pefile = [ {file = "pefile-2021.9.3.tar.gz", hash = "sha256:344a49e40a94e10849f0fe34dddc80f773a12b40675bf2f7be4b8be578bdd94a"}, ] @@ -451,6 +494,10 @@ pluggy = [ {file = "pluggy-0.13.1-py2.py3-none-any.whl", hash = "sha256:966c145cd83c96502c3c3868f50408687b38434af77734af1e9ca461a4081d2d"}, {file = "pluggy-0.13.1.tar.gz", hash = "sha256:15b2acde666561e1298d71b523007ed7364de07029219b604cf808bfa1c765b0"}, ] +poethepoet = [ + {file = "poethepoet-0.13.1-py3-none-any.whl", hash = "sha256:47e7b38c8b5412f840447f7612a9330697e8633e7500a7340b6734f50e26e380"}, + {file = "poethepoet-0.13.1.tar.gz", hash = "sha256:4f6962f17f5d5a453fd7fa66e3e7897e9191d4289148433efe441c81f2451a46"}, +] py = [ {file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"}, {file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"}, @@ -472,9 +519,14 @@ pyinstaller-hooks-contrib = [ {file = "pyinstaller-hooks-contrib-2022.4.tar.gz", hash = "sha256:b7f7da20e5b83c22219a21b8f849525e5f735197975313208f4e07ff9549cdaf"}, {file = "pyinstaller_hooks_contrib-2022.4-py2.py3-none-any.whl", hash = "sha256:b57a90bb8520d6e1dbbaaae416875e28fa5a3b74d2e40e330d02d1ccadacc38c"}, ] +pyopengl = [ + {file = "PyOpenGL-3.1.6-py2-none-any.whl", hash = "sha256:57c597d989178e1413002df6b923619f6d29807501dece1c60cc6f12c0c8e8a7"}, + {file = "PyOpenGL-3.1.6-py3-none-any.whl", hash = "sha256:a7139bc3e15d656feae1f7e3ef68c799941ed43fadc78177a23db7e946c20738"}, + {file = "PyOpenGL-3.1.6.tar.gz", hash = "sha256:8ea6c8773927eda7405bffc6f5bb93be81569a7b05c8cac50cd94e969dce5e27"}, +] pyparsing = [ - {file = "pyparsing-3.0.8-py3-none-any.whl", hash = "sha256:ef7b523f6356f763771559412c0d7134753f037822dad1b16945b7b846f7ad06"}, - {file = "pyparsing-3.0.8.tar.gz", hash = "sha256:7bf433498c016c4314268d95df76c81b842a4cb2b276fa3312cfb1e1d85f6954"}, + {file = "pyparsing-3.0.9-py3-none-any.whl", hash = "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc"}, + {file = "pyparsing-3.0.9.tar.gz", hash = "sha256:2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb"}, ] pyside6 = [ {file = "PySide6-6.3.0-cp36-abi3-macosx_10_9_universal2.whl", hash = "sha256:2517377c49b5d5c66afc51dab02814d76af1fc7545bf6b76b3d1de86ce9a4507"}, @@ -507,6 +559,10 @@ shiboken6 = [ {file = "shiboken6-6.3.0-cp36-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:e68e3cbb595c3047c4d893b84ef88eb5b23dea4e94241e80f5509dcb6613ad3d"}, {file = "shiboken6-6.3.0-cp36-abi3-win_amd64.whl", hash = "sha256:096e6b2254e59729ae61acbb80d09c31ad7ea35b6624ec120c15a35b95c70b69"}, ] +tomli = [ + {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, + {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, +] waitress = [ {file = "waitress-2.1.1-py3-none-any.whl", hash = "sha256:c549f5b2b4afd44d9d97d7cec79f3ef581e25d832827f415dc175327af674aa8"}, {file = "waitress-2.1.1.tar.gz", hash = "sha256:e2e60576cf14a1539da79f7b7ee1e79a71e64f366a0b47db54a15e971f57bb16"}, diff --git a/pyproject.toml b/pyproject.toml index 9492470..8f2c16a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "JellyPlayer" -version = "0.1.0" +version = "1.0.0" description = "Modern Jellyfin Client made with Python and Vue" authors = ["Prayag "] license = "GPL-3.0-only" @@ -14,16 +14,21 @@ keywords = [ ] [tool.poetry.dependencies] -python = "~3.9" -PySide6 = "^6.3.0" -Flask = "^2.1.2" -waitress = "^2.1.1" -python-mpv = "^1.0.1" -pyinstaller = "^5.0.1" +python = "~3.8" +PySide6 = "^6.3.0" +Flask = "^2.1.2" +waitress = "^2.1.1" +python-mpv = "^1.0.1" +pyinstaller = "^5.0.1" +PyOpenGL = "^3.1.6" [tool.poetry.dev-dependencies] pytest = "~5.2" +poethepoet = "^0.13.1" + +[tool.poe.tasks] +jellyplayer = "python jellyplayer/__init__.py" [build-system] requires = ["poetry-core>=1.0.0"] -build-backend = "poetry.core.masonry.api" +build-backend = "poetry.core.masonry.api" \ No newline at end of file