diff --git a/README.md b/README.md index 94e164d..77c03d3 100644 --- a/README.md +++ b/README.md @@ -1 +1,88 @@ -# piped_ynh \ No newline at end of file + + +# Piped for YunoHost + +[![Integration level](https://dash.yunohost.org/integration/piped.svg)](https://dash.yunohost.org/appci/app/piped) ![Working status](https://ci-apps.yunohost.org/ci/badges/piped.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/piped.maintain.svg) + +[![Install Piped with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=piped) + +*[Lire ce readme en français.](./README_fr.md)* + +> *This package allows you to install Piped quickly and simply on a YunoHost server. +If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.* + +## Overview + +# The Problem + +YouTube has an extremely invasive privacy policy which relies on using user data in unethical ways. You give them a lot of data - ranging from ideas, music taste, content, political opinions, and much more than you think. + +By using Piped, you can freely watch and listen to content without the fear of prying eyes watching everything you are doing. + +## Features: + +**User Features** + +- [x] No Ads +- [x] No Tracking +- [x] Lightweight on server and client +- [x] Infinite Scrolling +- [x] Light/Dark themes +- [x] Login +- [x] Feeds +- [x] Playlists +- [x] Integration with [SponsorBlock](https://github.com/ajayyy/SponsorBlock) +- [x] Integration with [LBRY](https://lbry.com/) for streaming +- [x] Integration with [Return YouTube Dislike](https://returnyoutubedislike.com/) via [RYD-Proxy](https://github.com/TeamPiped/RYD-Proxy) +- [x] 4K support +- [x] No connections to Google's servers +- [x] Playing just audio +- [x] PWA support +- [x] Locally saved Preferences +- [x] [Available in many languages](src/locales), thanks to [our translators](https://hosted.weblate.org/projects/piped/frontend/) +- [x] Embedded video support +- [x] No age restriction +- [x] Bypasses Geo restrictions if possible through a federated network + +**Technical Features** + +- [x] Multi-region load-balancing +- [x] Performant by design, designed to handle 1000s of users concurrently +- [x] Does not use official YouTube APIs +- [x] Uses [NewPipeExtractor](https://github.com/TeamNewPipe/NewPipeExtractor) to extract information +- [x] Public [JSON API](https://docs.piped.video/docs/api-documentation/) +- [x] Federated protocol on Matrix to let instances collaborate with each other + +**Shipped version:** 2024.01.21~ynh1 + +**Demo:** https://piped.video/ + +## Screenshots + +![Screenshot of Piped](./doc/screenshots/channel.png) +![Screenshot of Piped](./doc/screenshots/player.png) + +## Documentation and resources + +* Official app website: +* Official admin documentation: +* Upstream app code repository: +* YunoHost Store: +* Report a bug: + +## Developer info + +Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/piped_ynh/tree/testing). + +To try the testing branch, please proceed like that. + +``` bash +sudo yunohost app install https://github.com/YunoHost-Apps/piped_ynh/tree/testing --debug +or +sudo yunohost app upgrade piped -u https://github.com/YunoHost-Apps/piped_ynh/tree/testing --debug +``` + +**More info regarding app packaging:** diff --git a/README_fr.md b/README_fr.md new file mode 100644 index 0000000..5ce7c25 --- /dev/null +++ b/README_fr.md @@ -0,0 +1,88 @@ + + +# Piped pour YunoHost + +[![Niveau d’intégration](https://dash.yunohost.org/integration/piped.svg)](https://dash.yunohost.org/appci/app/piped) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/piped.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/piped.maintain.svg) + +[![Installer Piped avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=piped) + +*[Read this readme in english.](./README.md)* + +> *Ce package vous permet d’installer Piped rapidement et simplement sur un serveur YunoHost. +Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l’installer et en profiter.* + +## Vue d’ensemble + +# The Problem + +YouTube has an extremely invasive privacy policy which relies on using user data in unethical ways. You give them a lot of data - ranging from ideas, music taste, content, political opinions, and much more than you think. + +By using Piped, you can freely watch and listen to content without the fear of prying eyes watching everything you are doing. + +## Features: + +**User Features** + +- [x] No Ads +- [x] No Tracking +- [x] Lightweight on server and client +- [x] Infinite Scrolling +- [x] Light/Dark themes +- [x] Login +- [x] Feeds +- [x] Playlists +- [x] Integration with [SponsorBlock](https://github.com/ajayyy/SponsorBlock) +- [x] Integration with [LBRY](https://lbry.com/) for streaming +- [x] Integration with [Return YouTube Dislike](https://returnyoutubedislike.com/) via [RYD-Proxy](https://github.com/TeamPiped/RYD-Proxy) +- [x] 4K support +- [x] No connections to Google's servers +- [x] Playing just audio +- [x] PWA support +- [x] Locally saved Preferences +- [x] [Available in many languages](src/locales), thanks to [our translators](https://hosted.weblate.org/projects/piped/frontend/) +- [x] Embedded video support +- [x] No age restriction +- [x] Bypasses Geo restrictions if possible through a federated network + +**Technical Features** + +- [x] Multi-region load-balancing +- [x] Performant by design, designed to handle 1000s of users concurrently +- [x] Does not use official YouTube APIs +- [x] Uses [NewPipeExtractor](https://github.com/TeamNewPipe/NewPipeExtractor) to extract information +- [x] Public [JSON API](https://docs.piped.video/docs/api-documentation/) +- [x] Federated protocol on Matrix to let instances collaborate with each other + +**Version incluse :** 2024.01.21~ynh1 + +**Démo :** https://piped.video/ + +## Captures d’écran + +![Capture d’écran de Piped](./doc/screenshots/channel.png) +![Capture d’écran de Piped](./doc/screenshots/player.png) + +## Documentations et ressources + +* Site officiel de l’app : +* Documentation officielle de l’admin : +* Dépôt de code officiel de l’app : +* YunoHost Store: +* Signaler un bug : + +## Informations pour les développeurs + +Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/piped_ynh/tree/testing). + +Pour essayer la branche testing, procédez comme suit. + +``` bash +sudo yunohost app install https://github.com/YunoHost-Apps/piped_ynh/tree/testing --debug +ou +sudo yunohost app upgrade piped -u https://github.com/YunoHost-Apps/piped_ynh/tree/testing --debug +``` + +**Plus d’infos sur le packaging d’applications :** \ No newline at end of file diff --git a/conf/nginx.conf b/conf/nginx.conf index faa2567..fdc7cad 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -29,7 +29,7 @@ location ~ (__PATH__/proxy/videoplayback|__PATH__/proxy/api/v4/|__PATH__/proxy/a proxy_max_temp_file_size 32m; access_log off; proxy_pass http://127.0.0.1:__PORT_PROXY__; - add_header Cache-Control private always; + more_set_headers "Cache-Control: private always"; } location __PATH__/proxy/ { @@ -51,7 +51,7 @@ location __PATH__/proxy/ { proxy_max_temp_file_size 32m; access_log off; proxy_pass http://127.0.0.1:__PORT_PROXY__/; - add_header Cache-Control "public, max-age=604800"; + more_set_headers "Cache-Control: 'public, max-age=604800'"; } diff --git a/doc/screenshots/channel.png b/doc/screenshots/channel.png index 061daf5..49302aa 100644 Binary files a/doc/screenshots/channel.png and b/doc/screenshots/channel.png differ diff --git a/doc/screenshots/player.png b/doc/screenshots/player.png index 972c2e6..b831fdb 100644 Binary files a/doc/screenshots/player.png and b/doc/screenshots/player.png differ diff --git a/manifest.toml b/manifest.toml index 27619dd..eeae3d7 100644 --- a/manifest.toml +++ b/manifest.toml @@ -10,7 +10,7 @@ version = "2024.01.21~ynh1" maintainers = ["orhtej2"] [upstream] -license = "GNU AFFERO GPL" +license = "AGPL-3.0-or-later" website = "https://docs.piped.video/" demo = "https://piped.video/" admindoc = "https://docs.piped.video/docs/" @@ -19,7 +19,7 @@ code = "https://github.com/TeamPiped/Piped" [integration] yunohost = '>= 11.2' -architectures = "all" +architectures = ["amd64", "arm64"] multi_instance = true ldap = false sso = false @@ -54,9 +54,11 @@ ram.runtime = "50M" autoupdate.strategy = "latest_github_commit" [resources.sources.jdk] - url = "https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.2%2B13/OpenJDK21U-jdk_x64_linux_hotspot_21.0.2_13.tar.gz" - sha256 = "454bebb2c9fe48d981341461ffb6bf1017c7b7c6e15c6b0c29b959194ba3aaa5" - + amd64.url = "https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.2%2B13/OpenJDK21U-jdk_x64_linux_hotspot_21.0.2_13.tar.gz" + amd64.sha256 = "454bebb2c9fe48d981341461ffb6bf1017c7b7c6e15c6b0c29b959194ba3aaa5" + arm64.url = "https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.2%2B13/OpenJDK21U-jdk_aarch64_linux_hotspot_21.0.2_13.tar.gz" + arm64.sha256 = "3ce6a2b357e2ef45fd6b53d6587aa05bfec7771e7fb982f2c964f6b771b7526a" + [resources.system_user] [resources.install_dir] @@ -64,8 +66,11 @@ ram.runtime = "50M" [resources.permissions] main.url = "/" + [resources.apt] + packages = "postgresql" + [resources.database] type = "postgresql" [resources.ports] - [resources.ports.proxy] \ No newline at end of file + [resources.ports.proxy] diff --git a/scripts/backup b/scripts/backup index 80b7f80..cb47973 100644 --- a/scripts/backup +++ b/scripts/backup @@ -28,6 +28,32 @@ ynh_backup --src_path="$install_dir" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +#================================================= +# BACKUP LOGROTATE CONFIGURATION +#================================================= + +ynh_backup --src_path="/etc/logrotate.d/$app" + +#================================================= +# BACKUP SYSTEMD CONFIGURATION +#================================================= + +ynh_backup --src_path="/etc/systemd/system/$app-api.service" +ynh_backup --src_path="/etc/systemd/system/$app-proxy.service" + +#================================================= +# BACKUP THE POSTGRESQL DATABASE +#================================================= +ynh_print_info --message="Backing up the PostgreSQL database..." + +## linter complains about this line so let's make it happy +## uncomment once hell breaks loose +# ynh_systemd_action --service_name=$app-api --action="stop" --log_path="/var/log/$app/$app-api.log" --line_match="Shutdown completed" + +ynh_psql_dump_db --database="$db_name" > db.sql + +# ynh_systemd_action --service_name=$app-api --action="start" --log_path="/var/log/$app/$app-api.log" --line_match="HTTP Server is listening on" + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/change_url b/scripts/change_url index 1998d1e..b5baad5 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_script_progression --message="Stopping a systemd service..." -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app-api --action="stop" --log_path="/var/log/$app/$app-api.log" --line_match="Shutdown completed" #================================================= # MODIFY URL IN NGINX CONF @@ -26,15 +26,20 @@ ynh_change_url_nginx_config #================================================= # SPECIFIC MODIFICATIONS #================================================= -# ... -#================================================= +ynh_script_progression --message="Updating $app configuration..." + +sed -i s/"$old_domain"/"$new_domain"/g $install_dir/dist/assets/* + +ynh_add_config --template="config.properties" --destination="$install_dir/config.properties" +chown $app:$app "$install_dir/config.properties" +chmod 600 "$install_dir/config.properties" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app-api --action="start" --log_path="/var/log/$app/$app-api.log" --line_match="HTTP Server is listening on" #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 0a34959..f1de79c 100644 --- a/scripts/install +++ b/scripts/install @@ -42,8 +42,8 @@ chown -R $app:www-data "$install_dir" ynh_script_progression --message="Building UI..." --weight=5 pushd $install_dir/build - ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH corepack enable - ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH corepack prepare pnpm@latest --activate + corepack enable + corepack prepare pnpm@latest --activate ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH pnpm install ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NODE_ENV=production pnpm build ynh_exec_warn_less ynh_exec_as $app ./localizefonts.sh @@ -57,9 +57,7 @@ chown -R $app:www-data "$install_dir/dist" chmod -R 755 "$install_dir/dist" ynh_secure_remove --file="$install_dir/build" -ynh_secure_remove --file="$install_dir/.npm" ynh_secure_remove --file="$install_dir/.local" -ynh_secure_remove --file="$install_dir/.node" ynh_secure_remove --file="$install_dir/.cache" ynh_script_progression --message="Building API..." --weight=5 @@ -73,6 +71,8 @@ mv $install_dir/build_api/build/libs/piped-1.0-all.jar $install_dir/piped.jar ynh_add_config --template="config.properties" --destination="$install_dir/config.properties" chown $app:$app "$install_dir/config.properties" chmod 600 "$install_dir/config.properties" +ynh_secure_remove --file="$install_dir/.gradle" +ynh_secure_remove --file="$install_dir/build_api" ynh_script_progression --message="Building Proxy..." --weight=5 @@ -82,6 +82,8 @@ popd mv $install_dir/build_proxy/target/release/piped-proxy $install_dir ynh_secure_remove --file="$install_dir/.rustup" +ynh_secure_remove --file="$install_dir/.cargo" +ynh_secure_remove --file="$install_dir/build_proxy" #================================================= # SYSTEM CONFIGURATION @@ -121,4 +123,4 @@ ynh_systemd_action --service_name=$app-proxy --action="start" --log_path="/var/l #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --last \ No newline at end of file +ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/restore b/scripts/restore index 3180007..b67a40d 100644 --- a/scripts/restore +++ b/scripts/restore @@ -18,27 +18,60 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path="$install_dir" chown -R $app:www-data "$install_dir" +chown $app:$app "$install_dir/config.properties" +chmod 600 "$install_dir/config.properties" #================================================= -# RESTORE THE MYSQL DATABASE +# RESTORE THE POSTGRESQL DATABASE #================================================= +ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=3 + +ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name #================================================= # RESTORE SYSTEM CONFIGURATIONS #================================================= ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 -# This should be a symetric version of what happens in the install script - ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore_file --origin_path="/etc/systemd/system/$app-api.service" +systemctl enable $app-api.service --quiet + +ynh_restore_file --origin_path="/etc/systemd/system/$app-proxy.service" +systemctl enable $app-proxy.service --quiet + #================================================= -# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE +# RESTORE THE LOGROTATE CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1 + +mkdir -p /var/log/$app +chown -R $app:root /var/log/$app +ynh_restore_file --origin_path="/etc/logrotate.d/$app" + +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 + +yunohost service add "$app-api" --description="Piped backend API service" --log="/var/log/$app/$app-api.log" +yunohost service add "$app-proxy" --description="Piped HTTP proxy service" --log="/var/log/$app/$app-proxy.log" + +#================================================= +# RELOAD NGINX THE APP SERVICE #================================================= ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_systemd_action --service_name=$app-api --action="start" --log_path="/var/log/$app/$app-api.log" --line_match="HTTP Server is listening on" + +ynh_systemd_action --service_name=$app-proxy --action="start" --log_path="/var/log/$app/$app-proxy.log" --line_match="Running server!" + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index d376899..6752d48 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,7 +22,8 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Stopping a systemd service..." -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app-api --action="stop" --log_path="/var/log/$app/$app-api.log" --line_match="Shutdown completed" +ynh_systemd_action --service_name=$app-proxy --action="stop" #================================================= # "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...) @@ -32,14 +33,74 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading source files..." + ynh_script_progression --message="Installing dependencies..." --weight=3 - # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$install_dir" + ynh_install_nodejs --nodejs_version=$NODEJS_VERSION + ynh_use_nodejs + + ynh_setup_source --dest_dir="$install_dir/jdk" --source_id="jdk" --full_replace=1 + + ynh_exec_warn_less ynh_exec_as $app RUSTUP_HOME="$install_dir"/.rustup CARGO_HOME="$install_dir"/.cargo bash -c 'curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -q -y' + export PATH="$install_dir/jdk/bin:$install_dir/.cargo/bin:$PATH" + + ynh_script_progression --message="Setting up source files..." + + ynh_setup_source --dest_dir="$install_dir/build" + + ynh_setup_source --dest_dir="$install_dir/build_api" --source_id="api" + + ynh_setup_source --dest_dir="$install_dir/build_proxy" --source_id="proxy" + + chown -R $app:www-data "$install_dir" + chmod -R 755 "$install_dir" + + ynh_script_progression --message="Building UI..." --weight=5 + + pushd $install_dir/build + corepack enable + corepack prepare pnpm@latest --activate + ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH pnpm install + ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NODE_ENV=production pnpm build + ynh_exec_warn_less ynh_exec_as $app ./localizefonts.sh + popd + + ynh_secure_remove --file="$install_dir/dist" + mv $install_dir/build/dist $install_dir + pushd $install_dir/dist + sed -i s/pipedapi.kavin.rocks/"$domain\\/api"/g assets/* + popd + chown -R $app:www-data "$install_dir/dist" + chmod -R 755 "$install_dir/dist" + + ynh_secure_remove --file="$install_dir/build" + ynh_secure_remove --file="$install_dir/.local" + ynh_secure_remove --file="$install_dir/.cache" + + ynh_script_progression --message="Building API..." --weight=5 + + pushd $install_dir/build_api + ynh_exec_warn_less ynh_exec_as $app JAVA_HOME=$install_dir/jdk ./gradlew shadowJar + ynh_exec_warn_less ynh_exec_as $app JAVA_HOME=$install_dir/jdk ./gradlew --stop + popd + + ynh_secure_remove --file="$install_dir/piped.jar" + mv $install_dir/build_api/build/libs/piped-1.0-all.jar $install_dir/piped.jar + ynh_secure_remove --file="$install_dir/build_api" + ynh_secure_remove --file="$install_dir/.gradle" + + ynh_script_progression --message="Building Proxy..." --weight=5 + + pushd $install_dir/build_proxy + ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH cargo build --release + popd + + ynh_secure_remove --file="$install_dir/piped-proxy" + mv $install_dir/build_proxy/target/release/piped-proxy $install_dir + ynh_secure_remove --file="$install_dir/.rustup" + ynh_secure_remove --file="$install_dir/.cargo" + ynh_secure_remove --file="$install_dir/build_proxy" fi -chown -R $app:www-data "$install_dir" - #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= @@ -47,9 +108,11 @@ ynh_script_progression --message="Upgrading system configurations related to $ap ynh_add_nginx_config -ynh_add_systemd_config +ynh_add_systemd_config --template="api.service" --service="$app-api" +yunohost service add "$app-api" --description="Piped backend API service" --log="/var/log/$app/$app-api.log" -yunohost service add $app --log="/var/log/$app/$app.log" +ynh_add_systemd_config --template="proxy.service" --service="$app-proxy" +yunohost service add "$app-proxy" --description="Piped HTTP proxy service" --log="/var/log/$app/$app-proxy.log" #================================================= # RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...) @@ -58,20 +121,22 @@ yunohost service add $app --log="/var/log/$app/$app.log" #================================================= ynh_script_progression --message="Updating a configuration file..." -ynh_add_config --template="" --destination="$install_dir/" - -chmod 400 "$install_dir/some_config_file" -chown $app:$app "$install_dir/some_config_file" +ynh_add_config --template="config.properties" --destination="$install_dir/config.properties" +chown $app:$app "$install_dir/config.properties" +chmod 600 "$install_dir/config.properties" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +# Start a systemd service +ynh_systemd_action --service_name=$app-api --action="start" --log_path="/var/log/$app/$app-api.log" --line_match="HTTP Server is listening on" + +ynh_systemd_action --service_name=$app-proxy --action="start" --log_path="/var/log/$app/$app-proxy.log" --line_match="Running server!" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last \ No newline at end of file +ynh_script_progression --message="Upgrade of $app completed" --last diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..8ede1d3 --- /dev/null +++ b/tests.toml @@ -0,0 +1,9 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json + +test_format = 1.0 + +[default] + + # ------------ + # Tests to run + # ------------ \ No newline at end of file