Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use Clapper enhancers #1308

Merged
merged 9 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 50 additions & 4 deletions build-aux/dev.geopjr.Tuba.Clapper.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,27 @@
"mkdir -p /app/lib/ffmpeg"
],
"modules": [
{
"name": "libpeas",
"buildsystem": "meson",
"config-opts": [
"--wrap-mode=nodownload",
"-Dgjs=false",
"-Dlua51=false",
"-Dintrospection=false"
],
"sources": [
{
"type": "archive",
"url": "https://download.gnome.org/sources/libpeas/2.0/libpeas-2.0.5.tar.xz",
"sha256": "376f2f73d731b54e13ddbab1d91b6382cf6a980524def44df62add15489de6dd",
"x-checker-data": {
"type": "gnome",
"name": "libpeas"
}
}
]
},
{
"name": "clapper",
"buildsystem": "meson",
Expand All @@ -52,11 +73,36 @@
{
"type": "git",
"url": "https://github.com/Rafostar/clapper.git",
"branch": "master"
},
"tag": "0.8.0"
}
]
},
{
"name": "python-modules",
"buildsystem": "simple",
"build-commands": [
"pip3 install -v --root-user-action=ignore --no-deps --prefix=/app *.whl"
],
"sources": [
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/a4/97/73eadf12412173dc518897a2715693e6caa73d6550ddf0b7c47c6f1e7703/yt_dlp-2025.1.15-py3-none-any.whl",
"sha256": "b8666b88e23c3fa5ee1e80920f4a9dfac7c405504a447214c0cf3d0c386edcfc"
}
]
},
{
"name": "clapper-enhancers",
"buildsystem": "meson",
"config-opts": [
"-Dpeertube=enabled",
"-Dyt-dlp=enabled"
],
"sources": [
{
"type": "shell",
"commands": ["sed -i \"s/version: '0.7.0',/version: '0.8.0',/g\" meson.build"]
"type": "git",
"url": "https://github.com/Rafostar/clapper-enhancers.git",
"tag": "0.8.1"
}
]
},
Expand Down
86 changes: 84 additions & 2 deletions build-aux/dev.geopjr.Tuba.Devel.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,24 @@
"runtime": "org.gnome.Platform",
"runtime-version": "47",
"sdk": "org.gnome.Sdk",
"add-extensions": {
"org.freedesktop.Platform.ffmpeg-full": {
"version": "24.08",
"directory": "lib/ffmpeg",
"add-ld-path": ".",
"no-autodownload": false,
"autodelete": false
}
},
"command": "dev.geopjr.Tuba",
"finish-args": [
"--device=dri",
"--share=ipc",
"--share=network",
"--socket=fallback-x11",
"--socket=wayland",
"--socket=pulseaudio"
"--socket=pulseaudio",
"--own-name=org.mpris.MediaPlayer2.Tuba.*"
],
"cleanup": [
"/include",
Expand All @@ -24,7 +34,78 @@
"*.la",
"*.a"
],
"cleanup-commands": [
"mkdir -p /app/lib/ffmpeg"
],
"modules": [
{
"name": "libpeas",
"buildsystem": "meson",
"config-opts": [
"--wrap-mode=nodownload",
"-Dgjs=false",
"-Dlua51=false",
"-Dintrospection=false"
],
"sources": [
{
"type": "archive",
"url": "https://download.gnome.org/sources/libpeas/2.0/libpeas-2.0.5.tar.xz",
"sha256": "376f2f73d731b54e13ddbab1d91b6382cf6a980524def44df62add15489de6dd",
"x-checker-data": {
"type": "gnome",
"name": "libpeas"
}
}
]
},
{
"name": "clapper",
"buildsystem": "meson",
"config-opts": [
"-Dclapper=enabled",
"-Dclapper-gtk=enabled",
"-Dclapper-app=disabled",
"-Dintrospection=enabled",
"-Dvapi=enabled"
],
"sources": [
{
"type": "git",
"url": "https://github.com/Rafostar/clapper.git",
"tag": "0.8.0"
}
]
},
{
"name": "python-modules",
"buildsystem": "simple",
"build-commands": [
"pip3 install -v --root-user-action=ignore --no-deps --prefix=/app *.whl"
],
"sources": [
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/a4/97/73eadf12412173dc518897a2715693e6caa73d6550ddf0b7c47c6f1e7703/yt_dlp-2025.1.15-py3-none-any.whl",
"sha256": "b8666b88e23c3fa5ee1e80920f4a9dfac7c405504a447214c0cf3d0c386edcfc"
}
]
},
{
"name": "clapper-enhancers",
"buildsystem": "meson",
"config-opts": [
"-Dpeertube=enabled",
"-Dyt-dlp=enabled"
],
"sources": [
{
"type": "git",
"url": "https://github.com/Rafostar/clapper-enhancers.git",
"tag": "0.8.1"
}
]
},
{
"name" : "libspelling",
"buildsystem" : "meson",
Expand All @@ -44,7 +125,8 @@
"builddir": true,
"buildsystem": "meson",
"config-opts" : [
"-Ddevel=true"
"-Ddevel=true",
"-Dclapper=true"
],
"sources": [
{
Expand Down
2 changes: 1 addition & 1 deletion meson_options.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
option('devel', type: 'boolean', value: false)
option('distro', type: 'boolean', value: false)
option('clapper', type: 'boolean', value: false)
option('clapper', type: 'boolean', value: true)
65 changes: 49 additions & 16 deletions src/API/Status/PreviewCard.vala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ public class Tuba.API.PreviewCard : Entity, Widgetizable {
BASIC,
PEERTUBE,
FUNKWHALE,
BOOKWYRM;
BOOKWYRM,
CLAPPER;

public string to_string () {
switch (this) {
Expand All @@ -30,6 +31,8 @@ public class Tuba.API.PreviewCard : Entity, Widgetizable {
case BOOKWYRM:
// translators: the variable is an external service like "BookWyrm"
return _("You are about to open a %s book").printf (this.to_string ());
case CLAPPER:
return _("You are about to open a video");
default:
// translators: the variable is the app name (Tuba)
return _("You are about to leave %s").printf (Build.NAME);
Expand Down Expand Up @@ -65,11 +68,13 @@ public class Tuba.API.PreviewCard : Entity, Widgetizable {

public void parse_url (string t_url, out string special_host, out string special_api_url) throws Error {
switch (this) {
case PEERTUBE:
var peertube_instance = GLib.Uri.parse (t_url, GLib.UriFlags.NONE);
special_host = peertube_instance.get_host ();
special_api_url = @"https://$(special_host)/api/v1/videos/$(Path.get_basename (peertube_instance.get_path ()))";
break;
#if !CLAPPER
case PEERTUBE:
var peertube_instance = GLib.Uri.parse (t_url, GLib.UriFlags.NONE);
special_host = peertube_instance.get_host ();
special_api_url = @"https://$(special_host)/api/v1/videos/$(Path.get_basename (peertube_instance.get_path ()))";
break;
#endif
case FUNKWHALE:
var funkwhale_instance = GLib.Uri.parse (t_url, GLib.UriFlags.NONE);
special_host = funkwhale_instance.get_host ();
Expand Down Expand Up @@ -116,11 +121,30 @@ public class Tuba.API.PreviewCard : Entity, Widgetizable {
public CardSpecialType card_special_type {
get {
if (is_peertube) {
return CardSpecialType.PEERTUBE;
#if CLAPPER
try {
var uri = GLib.Uri.parse (this.url, GLib.UriFlags.NONE);
if (Clapper.enhancer_check (typeof (Clapper.Extractable), "peertube", uri.get_host (), null)) {
GeopJr marked this conversation as resolved.
Show resolved Hide resolved
return CardSpecialType.PEERTUBE;
}
} catch {}
return CardSpecialType.BASIC;
#else
return CardSpecialType.PEERTUBE;
#endif
} else if (is_funkwhale) {
return CardSpecialType.FUNKWHALE;
} else if (is_bookwyrm) {
return CardSpecialType.BOOKWYRM;
#if CLAPPER
} else {
try {
var uri = GLib.Uri.parse (this.url, GLib.UriFlags.NONE);
// TODO: maybe limit to https only
if (Clapper.enhancer_check (typeof (Clapper.Extractable), uri.get_scheme (), uri.get_host (), null))
return CardSpecialType.CLAPPER;
} catch {}
#endif
}

return CardSpecialType.BASIC;
Expand All @@ -140,12 +164,10 @@ public class Tuba.API.PreviewCard : Entity, Widgetizable {

public bool is_peertube {
get {
// Disable PeerTube support for now
// see #253
#if false
bool url_pt = url.last_index_of ("/videos/watch/") > -1;

return kind == "video" && provider_name == "PeerTube" && url_pt;
#if CLAPPER
return kind == "video" && provider_name == "PeerTube";
// Disable PeerTube support for now
// see #253
#else
return false;
#endif
Expand Down Expand Up @@ -174,9 +196,20 @@ public class Tuba.API.PreviewCard : Entity, Widgetizable {
}

public static void open_special_card (CardSpecialType card_special_type, string card_url) {
if (card_special_type.open_special_card (card_url)) {
return;
};
if (card_special_type.open_special_card (card_url)) return;

#if CLAPPER
if (card_special_type == API.PreviewCard.CardSpecialType.CLAPPER || card_special_type == API.PreviewCard.CardSpecialType.PEERTUBE) {
string fin_url = card_url;
if (card_special_type == API.PreviewCard.CardSpecialType.PEERTUBE) {
fin_url = fin_url.splice (0, fin_url.index_of_char ('/') + 2, "peertube://");
}

app.main_window.show_media_viewer (fin_url, Tuba.Attachment.MediaType.VIDEO, null, null, false, null, fin_url, null, true);
return;
}
#endif

string special_api_url = "";
string special_host = "";
try {
Expand Down
Loading