makedeb


netease-cloud-music-patched 1.2.1-8


Patched official Netease Cloud Music, re-ported from AUR

Click here to go back to the commit logs for netease-cloud-music-patched.

Commit:


Hash: 27f085a2055ff4eacf4b1546d5d66011d8c7e1c3

Message: fix failed to play SQ music (.flac file) Signed-off-by: kXuan <kxuanobj@gmail.com>

Diff


diff --git a/.SRCINFO b/.SRCINFO
index 36a602c..fb1eca3 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,7 +1,7 @@
 pkgbase = netease-cloud-music
 	pkgdesc = Netease Cloud Music, converted from .deb package
 	pkgver = 1.2.1
-	pkgrel = 4
+	pkgrel = 5
 	url = https://music.163.com/
 	arch = x86_64
 	license = custom
@@ -10,9 +10,13 @@ pkgbase = netease-cloud-music
 	depends = vlc
 	source = https://d1.music.126.net/dmusic/netease-cloud-music_1.2.1_amd64_ubuntu_20190428.deb
 	source = https://music.163.com/html/web2/service.html
+	source = patch.c
 	source = exclude.list
-	md5sums = 1f47c7dc3d9ce46da8099e539ee8a74d
-	md5sums = ee09cacb054f6a346bf935737df3f33d
-	md5sums = SKIP
+	source = netease-cloud-music.bash
+	sha256sums = 1ee9f02842e6c2c8c79c48b2e932074f9c213a8eb4238e5e63f20438562fecbb
+	sha256sums = cf307fee4be224223ed8cf5af5e8708960683564cd05c53108fa3c382c029a0e
+	sha256sums = 56ca2bef65508632b2cff48289a34082c6a780743f34eebfb9746f5480ee2015
+	sha256sums = 0c470e76741c549e5530b2e57d57281eaf198fd56ca3590f664154365b744cf9
+	sha256sums = b11bd6ab4abcc375850668f54a4912948875ad9f9b93cfc24f89de16ec1e8ea7
 
 pkgname = netease-cloud-music
diff --git a/.gitignore b/.gitignore
index b85dddf..7c9d4de 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
 *.tar.xz
 service.html
 *.deb
+tmp
diff --git a/PKGBUILD b/PKGBUILD
index baa9070..dc3ae74 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -4,7 +4,7 @@
 pkgname=netease-cloud-music
 pkgver=1.2.1
 _pkgdate=20190428
-pkgrel=4
+pkgrel=5
 pkgdesc="Netease Cloud Music, converted from .deb package"
 arch=("x86_64")
 url="https://music.163.com/"
@@ -13,16 +13,27 @@ depends=('gtk2' 'gtk3' 'vlc')
 source=(
 	"https://d1.music.126.net/dmusic/netease-cloud-music_${pkgver}_amd64_ubuntu_${_pkgdate}.deb"
 	"https://music.163.com/html/web2/service.html"
+    "patch.c"
     "exclude.list"
+    "netease-cloud-music.bash"
 )
 sha256sums=('1ee9f02842e6c2c8c79c48b2e932074f9c213a8eb4238e5e63f20438562fecbb'
             'cf307fee4be224223ed8cf5af5e8708960683564cd05c53108fa3c382c029a0e'
-            'SKIP')
+            '56ca2bef65508632b2cff48289a34082c6a780743f34eebfb9746f5480ee2015'
+            '0c470e76741c549e5530b2e57d57281eaf198fd56ca3590f664154365b744cf9'
+            'b11bd6ab4abcc375850668f54a4912948875ad9f9b93cfc24f89de16ec1e8ea7')
 
 DLAGENTS=("https::/usr/bin/curl -A 'Mozilla' -fLC - --retry 3 --retry-delay 3 -o %o %u")
 
+build() {
+  cd ${srcdir}
+  cc -O2 -fPIC -shared -I /usr/include/vlc/plugins/ -o libnetease-patch.so patch.c
+}
+
 package() {
   cd ${srcdir}
   tar -xf data.tar.xz -C ${pkgdir} --exclude-from=exclude.list
   install -D -m644 service.html ${pkgdir}/usr/share/licenses/$pkgname/license.html
+  install -D -m755 libnetease-patch.so ${pkgdir}/opt/netease/netease-cloud-music/libnetease-patch.so
+  install -D -m755 netease-cloud-music.bash ${pkgdir}/opt/netease/netease-cloud-music/netease-cloud-music.bash
 }
diff --git a/exclude.list b/exclude.list
index f4b8a4c..3e61dcd 100644
--- a/exclude.list
+++ b/exclude.list
@@ -1,3 +1,6 @@
+# replace netease-cloud-music.bash with this AUR package
+./opt/netease/netease-cloud-music/netease-cloud-music.bash
+
 # Fix unable to use fcitx
 # gtk or gdk and its dependencies
 ./opt/netease/netease-cloud-music/libs/libgtk-3.so.0
diff --git a/netease-cloud-music.bash b/netease-cloud-music.bash
new file mode 100755
index 0000000..e3240b1
--- /dev/null
+++ b/netease-cloud-music.bash
@@ -0,0 +1,8 @@
+#!/bin/sh
+HERE="$(dirname "$(readlink -f "${0}")")"
+export LD_LIBRARY_PATH="${HERE}"/libs
+export QT_PLUGIN_PATH="${HERE}"/plugins 
+export QT_QPA_PLATFORM_PLUGIN_PATH="${HERE}"/plugins/platforms
+export LD_PRELOAD="${HERE}"/libnetease-patch.so
+
+exec "${HERE}"/netease-cloud-music $@
diff --git a/patch.c b/patch.c
new file mode 100644
index 0000000..12c401a
--- /dev/null
+++ b/patch.c
@@ -0,0 +1,71 @@
+// SPDX-License-Identifier: BSD-3-Clause
+
+#define _GNU_SOURCE
+
+#include <dlfcn.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <sys/prctl.h>
+#include <vlc/vlc.h>
+#include <vlc/plugins/vlc_common.h>
+#include <vlc/plugins/vlc_stream.h>
+
+typedef int(*fn_vlc_stream_vaControl)(stream_t *s, int query, va_list args);
+
+static fn_vlc_stream_vaControl orig_vlc_stream_vaControl;
+
+static int is_flac(const char *url)
+{
+    static const char suffix[] = ".flac";
+    if (!url) {
+        return 0;
+    }
+    size_t len = strlen(url);
+    if (len < sizeof(suffix)) {
+        return 0;
+    }
+
+    return strcasecmp(url + len - sizeof(suffix) + 1, suffix) == 0;
+}
+
+int vlc_stream_vaControl(stream_t *s, int query, va_list args)
+{
+    if (query == STREAM_GET_CONTENT_TYPE && is_flac(s->psz_url)) {
+        *va_arg(args, char **) = strdup("audio/flac");
+        return VLC_SUCCESS;
+    } else {
+        return orig_vlc_stream_vaControl(s, query, args);
+    }
+}
+
+static void load_sym(void *ptrfunc, void *override_func, const char *name)
+{
+    void *ptr = dlsym(RTLD_NEXT, name);
+    if (ptr == NULL) {
+        fprintf(stderr, "Cannot load symbol '%s' %s. Please report bug on AUR.\n", name, dlerror());
+        exit(1);
+    }
+    if (ptr == override_func) {
+        fprintf(stderr, "circular reference '%s'. Please report bug on AUR.\n", name);
+        exit(1);
+    }
+    *(void **)ptrfunc = ptr;
+}
+
+__attribute__((constructor))
+static void init(void)
+{
+    char progname[16] = {0};
+    int rc;
+
+    rc = prctl(PR_GET_NAME, progname);
+    if (rc != 0) {
+        return;
+    }
+    if (strcmp(progname, "netease-cloud-m") != 0) {
+        return;
+    }
+
+    load_sym(&orig_vlc_stream_vaControl, vlc_stream_vaControl, "vlc_stream_vaControl");
+}