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

[Radio3.0@claudiux] v2.7.0: You can choose the Quality of the downloaded Album Art #6747

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions Radio3.0@claudiux/files/Radio3.0@claudiux/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### v2.7.0~20250107
* You can choose the Quality of the downloaded album cover.
* Desklet AlbumArt3.0: New option in context menu to display the Album Art at full size. Middle-clicking on the desklet does the same.
* Bufixes in applet and in desklet.

### v2.6.1~20250106
* Fixes desklet issue for Cinnamon 6.0.

Expand Down
16 changes: 12 additions & 4 deletions Radio3.0@claudiux/files/Radio3.0@claudiux/applet.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ const QUEUE = 1;
var VERSION, METADATA;

let dummy = _("unassigned"); // Only for translation.
dummy = _("Display Album Art at full size"); // used in desklet.
dummy = undefined;

var radioppConfigFilePath = HOME_DIR + "/.cinnamon/configs/radio@driglu4it/[email protected]";
if (!file_test(radioppConfigFilePath, FileTest.EXISTS)) {
Expand Down Expand Up @@ -1310,6 +1312,7 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {
}

get_user_settings() {
this.settings.bind("image-resolution", "res", this.reload_songArt.bind(this));
this.settings.bind("radiopp-is-here", "radiopp_is_here");
this.radiopp_is_here = radioppConfigFilePath != null;
this.settings.bind("desklet-x", "desklet_x");
Expand Down Expand Up @@ -1737,7 +1740,7 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {
let reg = new RegExp(`rgb[(]([0-9]+),([0-9]+),([0-9]+)[)]`);
let color = "%s".format(this.settings.getValue("color-on"));
let [, red, green, blue] = reg.exec(color);
let alpha_value = Math.ceil(2.55 * this.progress);
let alpha_value = Math.min(Math.ceil(2.55 * this.progress), 255);
let alpha = ""+alpha_value;
this.actor.style = "color: rgba(%s,%s,%s,%s)".format(red, green, blue, alpha);

Expand Down Expand Up @@ -3406,19 +3409,24 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {
this.updateUI();

if (!has_no_title)
this.download_songArt(title);
this.download_songArt(title, this.res);

pid = null;
}

download_songArt(title) {
download_songArt(title, res="") {
if (!YTDL_PROGRAM().includes("yt-dlp")) return;

let command = '%s/get_song_art.sh "%s"'.format(SCRIPTS_DIR, title);
let command = '%s/get_song_art.sh "%s" "%s"'.format(SCRIPTS_DIR, title, res);
//~ log("command: "+command, true);
spawnCommandLineAsync(command);
}

reload_songArt() {
if (this.songTitle && this.songTitle.length > 0)
this.download_songArt(this.songTitle, this.res);
}

change_selected_item() {
//log("change_selected_item");
var radios = this.settings.getValue("radios");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//"use strict";
const Main = imports.ui.main;
const Gio = imports.gi.Gio;
const PopupMenu = imports.ui.popupMenu;
const St = imports.gi.St;
const Desklet = imports.ui.desklet;
const Lang = imports.lang;
Expand Down Expand Up @@ -101,7 +102,7 @@ class AlbumArtRadio30 extends Desklet.Desklet {
this.dir_monitor_loop_is_active = false;

if (this._bin != null) {
this._bin.removeTween();
Tweener.removeTweens(this._bin);
this._bin.destroy_all_children();
this._bin.destroy();
this._bin = null;
Expand All @@ -111,7 +112,8 @@ class AlbumArtRadio30 extends Desklet.Desklet {
_scan_dir(dir) {
if (!this.isLooping) return;
let dir_file = Gio.file_new_for_uri(dir);
let fileEnum = dir_file.enumerate_children('standard::type,standard::name,standard::is-hidden', Gio.FileQueryInfoFlags.NONE, null);
//~ let fileEnum = dir_file.enumerate_children('standard::type,standard::name,standard::is-hidden', Gio.FileQueryInfoFlags.NONE, null);
let fileEnum = dir_file.enumerate_children('standard::*', Gio.FileQueryInfoFlags.NONE, null);

let info;
while ((info = fileEnum.next_file(null)) != null) {
Expand Down Expand Up @@ -261,6 +263,20 @@ class AlbumArtRadio30 extends Desklet.Desklet {
}
}

/**
* on_desklet_added_to_desktop:
*
* This function is called by deskletManager when the desklet is added to the desktop.
*/
on_desklet_added_to_desktop(userEnabled) {
// Set "Display Album Art at full size" menu item, in top position:
let displayCoverArtInRealSize = new PopupMenu.PopupIconMenuItem(_("Display Album Art at full size"), "image-x-generic-symbolic", St.IconType.SYMBOLIC);
displayCoverArtInRealSize.connect("activate", (event) => {
GLib.spawn_command_line_async("xdg-open "+this.currentPicture.path);
});
this._menu.addMenuItem(displayCoverArtInRealSize, 0); // 0 for top position.
}

_loadImage(filePath) {
try {
let image = St.TextureCache.get_default().load_uri_async(filePath, this.width, this.height);
Expand Down
2 changes: 1 addition & 1 deletion Radio3.0@claudiux/files/Radio3.0@claudiux/metadata.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"description": "The Ultimate Internet Radio Receiver & Recorder for Cinnamon",
"max-instances": 1,
"version": "2.6.1",
"version": "2.7.0",
"uuid": "Radio3.0@claudiux",
"name": "Radio3.0",
"author": "claudiux",
Expand Down
Loading
Loading