Subject: [bug#70078] [PATCH v2] gnu: Add stremio.

From: Sergio Pastor Pérez <[email-masked]>
Date: Sat, 5 Apr 2025 20:00:00 +0200

* gnu/packages/video.scm (stremio): New variable.

Change-Id: Ie4c2dc30a0d488e20be21c3802330e993a60df70
---
 gnu/packages/video.scm | 112 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 112 insertions(+)

diff --git a/gnu/packages/video.scm b/gnu/packages/video.scm
index 0ddfc022a9..54dfb8ccc9 100644
--- a/gnu/packages/video.scm
+++ b/gnu/packages/video.scm
@@ -177,6 +177,7 @@ (define-module (gnu packages video)
   #:use-module (gnu packages ncurses)
   #:use-module (gnu packages nettle)
   #:use-module (gnu packages networking)
+  #:use-module (gnu packages node)
   #:use-module (gnu packages ocr)
   #:use-module (gnu packages pcre)
   #:use-module (gnu packages pciutils)
@@ -3844,6 +3845,117 @@ (define-public streamlink
 from sites like Twitch.tv and pipes them into a video player of choice.")
     (license license:bsd-2)))
 
+(define-public stremio
+  (define server-js
+    (let ((version "4.20.8"))
+      (origin
+        (method url-fetch)
+        (uri (string-append "https://dl.strem.io/server/v" version
+                            "/desktop/server.js"))
+        (file-name (string-append "stremio-server-" version ".js"))
+        (sha256 (base32 "0xmlbx6aib5h78ya369pnpxyn05b12l05i8v2kymijbmaw7j04vi")))))
+  (package
+    (name "stremio")
+    (version "4.4.168")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/Stremio/stremio-shell")
+             (commit (string-append "v" version))
+             ;; NOTE: submodules are embedded libraries so there is no reason
+             ;; to unbundle them.
+             (recursive? #t)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "14x9i8qvm19sijh7hqppbk8s14dvv7dqlck7x3s8n9i4xn4ncgd7"))))
+    (build-system qt-build-system)
+    (arguments
+     (list
+      #:tests? #f
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'unpack 'setup-server
+            (lambda _
+              (copy-file #$server-js "server.js")))
+          (add-after 'unpack 'fix-paths
+            (lambda* (#:key inputs #:allow-other-keys)
+              (substitute* "CMakeLists.txt"
+                (("opt/stremio")
+                 "bin"))
+              (substitute* "release.makefile"
+                (("/opt/stremio")
+                 "/bin"))
+              (substitute* "main.qml"
+                (("var node_executable =.*$")
+                 (string-append "var node_executable =\""
+                                (search-input-file inputs "bin/node") "\"\n"))
+                (("applicationDirPath \\+\"/server\\.js\"")
+                 (string-append "\""
+                                #$server-js "\"")))
+              (substitute* "smartcode-stremio.desktop"
+                (("Exec=stremio")
+                 (string-append "Exec="
+                                #$output "/bin/stremio")))))
+          (replace 'configure
+            (lambda _
+              (invoke "qmake")))
+          (replace 'build
+            (lambda _
+              (invoke "make" "-f" "release.makefile"
+                      (string-append "PREFIX="
+                                     #$output))))
+          (replace 'install
+            (lambda _
+              (invoke "make" "-f" "release.makefile" "install"
+                      (string-append "PREFIX="
+                                     #$output))
+              (with-directory-excursion #$output
+                ;; Setup desktop file.
+                (let ((dir "share/applications")
+                      (desktop "smartcode-stremio.desktop"))
+                  (mkdir-p "share/applications")
+                  (copy-file (string-append "bin/" desktop)
+                             (string-append dir "/" desktop))
+                  (delete-file (string-append "bin/" desktop)))
+                ;; Setup icon dir.
+                (for-each (lambda (size)
+                            (let ((dir (string-append "share/icons/hicolor/"
+                                                      size "x" size "/apps")))
+                              (mkdir-p dir)
+                              (copy-file (string-append
+                                          "bin/icons/smartcode-stremio_" size
+                                          ".png")
+                                         (string-append dir
+                                          "/smartcode-stremio.png"))
+                              (copy-file (string-append
+                                          "bin/icons/smartcode-stremio-tray_"
+                                          size ".png")
+                                         (string-append dir
+                                          "/smartcode-stremio-tray.png"))))
+                          '("16" "22" "24" "32" "64" "128"))
+                ;; Remove unnecessary opt dir.
+                (delete-file-recursively "bin/icons")))))))
+    (inputs (list librsvg
+                  mpv
+                  node
+                  openssl
+                  qtdeclarative-5
+                  qtquickcontrols-5
+                  qtwebchannel-5
+                  qtwebengine-5
+                  qtbase-5))
+    (home-page "https://www.stremio.com")
+    (synopsis "Modern media center that gives you the freedom to watch
+everything you want")
+    (description
+     "Stremio offers a secure, modern and seamless entertainment experience.
+With its easy-to-use interface and diverse content library, including 4K HDR
+support, users can enjoy their favorite movies and TV shows across all their
+devices.  And with its commitment to security, Stremio is the ultimate choice
+for a worry-free, high-quality streaming experience.")
+    (license license:expat)))
+
 (define-public twitchy
   (let ((commit "9beb36d80b16662414129693e74fa3a2fd97554e")) ; 3.4 has no tag
     (package

base-commit: bcfb283cda1b782129c8a70b69d216b925501185
-- 
2.49.0