diff --git a/.github/workflows/desktop.yml b/.github/workflows/desktop.yml
new file mode 100644
index 000000000..143914cb6
--- /dev/null
+++ b/.github/workflows/desktop.yml
@@ -0,0 +1,104 @@
+name: Desktop
+
+on:
+ push:
+ paths:
+ - 'desktop/**'
+ - 'PipePipeExtractor'
+ - '.github/workflows/desktop.yml'
+ tags:
+ - 'desktop-v*'
+ pull_request:
+ paths:
+ - 'desktop/**'
+ workflow_dispatch:
+
+permissions:
+ contents: write
+
+jobs:
+ build:
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - os: ubuntu-latest
+ name: linux-x64
+ - os: windows-latest
+ name: windows-x64
+ - os: macos-latest
+ name: macos-arm64
+ runs-on: ${{ matrix.os }}
+ defaults:
+ run:
+ shell: bash
+ steps:
+ - uses: actions/checkout@v4
+
+ # only the extractor is needed (the other submodules use SSH URLs)
+ - name: Checkout PipePipeExtractor submodule
+ run: git submodule update --init --depth 1 PipePipeExtractor
+
+ - uses: actions/setup-java@v4
+ with:
+ distribution: temurin
+ java-version: '25'
+ cache: gradle
+
+ - name: Build fat jar
+ working-directory: desktop
+ run: ./gradlew --no-daemon fatJar
+
+ - name: Package self-contained app (bundled JRE)
+ working-directory: desktop
+ run: |
+ VERSION=$(grep "^version" build.gradle | sed "s/.*'\(.*\)'.*/\1/")
+ mkdir -p dist
+ ICON=""
+ if [ "${{ runner.os }}" = "Linux" ]; then ICON="--icon src/main/resources/web/icon.png"; fi
+ jpackage --type app-image \
+ --name PipePipe \
+ --app-version "$VERSION" \
+ --vendor "PipePipe Desktop" \
+ --input build/libs \
+ --main-jar "pipepipe-desktop-${VERSION}-all.jar" \
+ --java-options "-XX:+UseSerialGC -Xss512k" \
+ --add-modules java.base,java.desktop,java.naming,java.net.http,java.sql,jdk.httpserver,jdk.unsupported,jdk.crypto.ec,java.management,java.logging,jdk.localedata,java.xml \
+ --jlink-options "--strip-debug --no-man-pages --no-header-files --compress=zip-6" \
+ $ICON \
+ --dest dist
+ find dist -name "*.debuginfo" -delete
+ cd dist
+ if [ "${{ runner.os }}" = "Windows" ]; then
+ 7z a "../PipePipe-${{ matrix.name }}.zip" PipePipe > /dev/null
+ elif [ "${{ runner.os }}" = "macOS" ]; then
+ ditto -c -k --keepParent PipePipe.app "../PipePipe-${{ matrix.name }}.zip"
+ else
+ tar czf "../PipePipe-${{ matrix.name }}.tar.gz" PipePipe
+ fi
+
+ - uses: actions/upload-artifact@v4
+ with:
+ name: PipePipe-${{ matrix.name }}
+ path: |
+ desktop/PipePipe-${{ matrix.name }}.*
+
+ - uses: actions/upload-artifact@v4
+ if: matrix.name == 'linux-x64'
+ with:
+ name: pipepipe-desktop-jar
+ path: desktop/build/libs/*-all.jar
+
+ release:
+ if: startsWith(github.ref, 'refs/tags/desktop-v')
+ needs: build
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/download-artifact@v4
+ with:
+ path: out
+ merge-multiple: true
+ - name: Publish release
+ env:
+ GH_TOKEN: ${{ github.token }}
+ run: gh release create "${GITHUB_REF_NAME}" out/* --repo "${GITHUB_REPOSITORY}" --title "PipePipe Desktop ${GITHUB_REF_NAME#desktop-v}" --generate-notes
diff --git a/.gitmodules b/.gitmodules
index 8b8af6bf8..7b1b3d21e 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -12,7 +12,7 @@
branch = main
[submodule "PipePipeClient"]
path = PipePipeClient
- url = git@github.com:InfinityLoop1308/PipePipeClient.git
+ url = https://github.com/InfinityLoop1308/PipePipeClient.git
[submodule "PipePipeExtractor"]
path = PipePipeExtractor
- url = git@github.com:InfinityLoop1308/PipePipeExtractor.git
+ url = https://github.com/InfinityLoop1308/PipePipeExtractor.git
diff --git a/PipePipeExtractor b/PipePipeExtractor
index 1a09d20e6..56379dcd5 160000
--- a/PipePipeExtractor
+++ b/PipePipeExtractor
@@ -1 +1 @@
-Subproject commit 1a09d20e68dbd0892995bc58ffa539049a656690
+Subproject commit 56379dcd546e9723dddca52d59aa6d8c562188d2
diff --git a/README.md b/README.md
index 899baa5b1..60c8c6773 100644
--- a/README.md
+++ b/README.md
@@ -7,6 +7,8 @@ NewPipe, reimagined: faster, more stable, and packed with more features.

+ * pipepipe-desktop start + open an app window (Chrome/Edge/Chromium app mode) + * pipepipe-desktop --server headless web server only + * options: --host 127.0.0.1 --port 47615 --data DIR --web DIR (serve UI from disk, dev) + *+ */ +public final class Main { + static final int DEFAULT_PORT = 47615; + + private Main() { } + + public static void main(final String[] args) throws Exception { + String host = "127.0.0.1"; + int port = DEFAULT_PORT; + boolean serverOnly = false; + Path data = defaultDataDir(); + Path web = null; + for (int i = 0; i < args.length; i++) { + switch (args[i]) { + case "--server" -> serverOnly = true; + case "--host" -> host = args[++i]; + case "--port" -> port = Integer.parseInt(args[++i]); + case "--data" -> data = Path.of(args[++i]); + case "--web" -> web = Path.of(args[++i]); + case "-h", "--help" -> { + System.out.println("usage: pipepipe-desktop [--server] [--host H] [--port P] [--data DIR]"); + return; + } + default -> System.err.println("unknown option " + args[i]); + } + } + Files.createDirectories(data); + + final String local = "http://127.0.0.1:" + port + "/"; + if (!serverOnly && isOurs(local)) { + // already running: just bring up another window + openWindow(local, data); + return; + } + + final DesktopDownloader downloader = new DesktopDownloader(); + NewPipe.init(downloader); + silenceExtractorLogs(); + Server server; + try { + server = new Server(host, port, downloader, new Store(data), web); + } catch (final java.net.BindException e) { + server = new Server(host, 0, downloader, new Store(data), web); + } + server.start(); + final String url = "http://127.0.0.1:" + server.port() + "/"; + System.out.println("PipePipe Desktop running at " + url + " (data: " + data + ")"); + if (!"127.0.0.1".equals(host) && !"localhost".equals(host)) { + System.out.println("WARNING: listening on " + host + " - anyone on this network can use it."); + } + if (serverOnly) { + return; // HTTP server threads keep the JVM alive + } + final Process window = openWindow(url, data); + if (window != null) { + // dedicated browser profile: when the window closes, the app quits. + // A process that exits right away handed off to an already running browser + // instance, so we cannot tell when the window closes -> keep running with a tray icon. + final long started = System.currentTimeMillis(); + window.waitFor(); + if (System.currentTimeMillis() - started > 4000) { + server.stop(); + System.exit(0); + } + } + final Server s = server; + tray(url, data, () -> { + s.stop(); + System.exit(0); + }); + } + + /** Tray icon with open / quit, used when we do not own the window process. */ + private static void tray(final String url, final Path data, final Runnable quit) { + try { + if (java.awt.GraphicsEnvironment.isHeadless() || !java.awt.SystemTray.isSupported()) { + System.out.println("Running. Press Ctrl+C to quit."); + return; + } + final java.awt.Image img; + try (var in = Main.class.getResourceAsStream("/web/icon.png")) { + img = javax.imageio.ImageIO.read(in); + } + final java.awt.PopupMenu menu = new java.awt.PopupMenu(); + final java.awt.MenuItem open = new java.awt.MenuItem("Open PipePipe"); + open.addActionListener(e -> openWindow(url, data)); + final java.awt.MenuItem exit = new java.awt.MenuItem("Quit"); + exit.addActionListener(e -> quit.run()); + menu.add(open); + menu.add(exit); + final java.awt.TrayIcon icon = new java.awt.TrayIcon(img, "PipePipe", menu); + icon.setImageAutoSize(true); + icon.addActionListener(e -> openWindow(url, data)); + java.awt.SystemTray.getSystemTray().add(icon); + } catch (final Exception e) { + System.out.println("Running at " + url + " - press Ctrl+C to quit."); + } + } + + /** The extractor prints a YT_PERF timing line per request; hide them unless debugging. */ + private static void silenceExtractorLogs() { + if (!"1".equals(System.getenv("PIPEPIPE_DEBUG"))) { + final var original = System.out; + System.setOut(new java.io.PrintStream(original, true) { + @Override + public void println(final String x) { + if (x == null || !x.startsWith("YT_PERF")) { + super.println(x); + } + } + }); + } + } + + private static boolean isOurs(final String base) { + try { + final HttpURLConnection c = (HttpURLConnection) URI.create(base + "api/ping").toURL().openConnection(); + c.setConnectTimeout(300); + c.setReadTimeout(600); + return c.getResponseCode() == 200 + && new String(c.getInputStream().readAllBytes()).contains("pipepipe-desktop"); + } catch (final Exception e) { + return false; + } + } + + static Path defaultDataDir() { + final String os = System.getProperty("os.name").toLowerCase(Locale.ROOT); + final String home = System.getProperty("user.home"); + if (os.contains("win")) { + final String appData = System.getenv("APPDATA"); + return Path.of(appData != null ? appData : home, "PipePipe Desktop"); + } + if (os.contains("mac")) { + return Path.of(home, "Library", "Application Support", "PipePipe Desktop"); + } + final String xdg = System.getenv("XDG_DATA_HOME"); + return Path.of(xdg != null && !xdg.isBlank() ? xdg : home + "/.local/share", "pipepipe-desktop"); + } + + private static List