mirror of
https://gitlab.com/liyaowhen/youtubecollector-git.git
synced 2026-10-01 01:12:59 +00:00
basically working export playlist to another folder
This commit is contained in:
@@ -34,6 +34,47 @@ namespace YoutubeCollector {
|
|||||||
add_song_to_playlist_action.activate.connect(add_song_to_playlist);
|
add_song_to_playlist_action.activate.connect(add_song_to_playlist);
|
||||||
this.add_action_entries (action_entries, this);
|
this.add_action_entries (action_entries, this);
|
||||||
this.add_action(add_song_to_playlist_action);
|
this.add_action(add_song_to_playlist_action);
|
||||||
|
var open_playlist_folder_action = new SimpleAction("open_playlist_folder", null);
|
||||||
|
this.add_action (open_playlist_folder_action);
|
||||||
|
open_playlist_folder_action.activate.connect(() => {
|
||||||
|
var playlist_folder = Path.build_filename (Environment.get_user_data_dir (), "com.liyaowhen.YoutubeCollector", AppController.main_view_content.current_playlist.name);
|
||||||
|
AppLaunchContext context = new AppLaunchContext ();
|
||||||
|
AppInfo.launch_default_for_uri (File.new_for_path (playlist_folder).get_uri (), context);
|
||||||
|
});
|
||||||
|
var export_playlist_action = new SimpleAction("export_playlist_folder", null);
|
||||||
|
this.add_action (export_playlist_action);
|
||||||
|
export_playlist_action.activate.connect(() => {
|
||||||
|
var file_chooser = new Gtk.FileDialog();
|
||||||
|
file_chooser.select_folder.begin (null, null, (obj, res) => {
|
||||||
|
try {
|
||||||
|
var target = File.new_build_filename(file_chooser.select_folder.end(res).get_path(), AppController.main_view_content.current_playlist.name);
|
||||||
|
if (!target.query_exists(null)) {
|
||||||
|
target.make_directory_with_parents (null);
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
// catch error
|
||||||
|
}
|
||||||
|
FileInfo file_info;
|
||||||
|
var playlist_folder = Path.build_filename (Environment.get_user_data_dir (), "com.liyaowhen.YoutubeCollector", AppController.main_view_content.current_playlist.name);
|
||||||
|
var _playlist_folder = File.new_for_path (playlist_folder);
|
||||||
|
var enumerator = _playlist_folder.enumerate_children ("standard::*", FileQueryInfoFlags.NONE);
|
||||||
|
while ((file_info = enumerator.next_file(null)) != null) {
|
||||||
|
try {
|
||||||
|
var source_file = _playlist_folder.get_child(file_info.get_name());
|
||||||
|
var target_file = target.get_child(file_info.get_name());
|
||||||
|
source_file.copy_async.begin (target_file, GLib.FileCopyFlags.NONE, 3, null, (progress, total) => {
|
||||||
|
// implement progress
|
||||||
|
});
|
||||||
|
} catch (Error e) {
|
||||||
|
print("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Error e) {
|
||||||
|
print("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
this.set_accels_for_action ("app.quit", {"<primary>q"});
|
this.set_accels_for_action ("app.quit", {"<primary>q"});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace YoutubeCollector {
|
|||||||
public static Adw.OverlaySplitView split_view;
|
public static Adw.OverlaySplitView split_view;
|
||||||
public static MainView main_view;
|
public static MainView main_view;
|
||||||
|
|
||||||
public static SongControls song_controls;
|
//public static SongControls song_controls;
|
||||||
|
|
||||||
public static YoutubeCollector.Window window;
|
public static YoutubeCollector.Window window;
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ youtubecollector_sources = [
|
|||||||
'widgets/yt_search.vala',
|
'widgets/yt_search.vala',
|
||||||
'background.vala',
|
'background.vala',
|
||||||
'widgets/import_playlist_popover.vala',
|
'widgets/import_playlist_popover.vala',
|
||||||
|
'widgets/media_player_popup.vala',
|
||||||
]
|
]
|
||||||
|
|
||||||
youtubecollector_deps = [
|
youtubecollector_deps = [
|
||||||
|
|||||||
@@ -163,14 +163,14 @@ namespace YoutubeCollector {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
var controls = new SongControls();
|
/*var controls = new SongControls();
|
||||||
controls_revealer.set_child(controls);
|
controls_revealer.set_child(controls);
|
||||||
controls_revealer.set_reveal_child(true);
|
controls_revealer.set_reveal_child(true);
|
||||||
controls_revealer.transition_type = Gtk.RevealerTransitionType.SLIDE_UP;
|
controls_revealer.transition_type = Gtk.RevealerTransitionType.SLIDE_UP;*/
|
||||||
|
|
||||||
toolbar_view.add_top_bar (action_bar);
|
toolbar_view.add_top_bar (action_bar);
|
||||||
toolbar_view.set_content(scrollable);
|
toolbar_view.set_content(scrollable);
|
||||||
toolbar_view.add_bottom_bar (controls_revealer);
|
//toolbar_view.add_bottom_bar (controls_revealer);
|
||||||
|
|
||||||
this.child = toolbar_view;
|
this.child = toolbar_view;
|
||||||
this.title = "main_view";
|
this.title = "main_view";
|
||||||
@@ -183,7 +183,7 @@ namespace YoutubeCollector {
|
|||||||
var signal_hub = SignalHub.get_instance();
|
var signal_hub = SignalHub.get_instance();
|
||||||
signal_hub.enter_yt_search_mode.connect(() => {
|
signal_hub.enter_yt_search_mode.connect(() => {
|
||||||
add_buttons_revealer.set_reveal_child(false);
|
add_buttons_revealer.set_reveal_child(false);
|
||||||
controls_revealer.set_reveal_child(false);
|
//controls_revealer.set_reveal_child(false);
|
||||||
exit_yt_search_mode_revealer.set_reveal_child(true);
|
exit_yt_search_mode_revealer.set_reveal_child(true);
|
||||||
action_bar.set_margin_start(-5);
|
action_bar.set_margin_start(-5);
|
||||||
|
|
||||||
@@ -191,7 +191,7 @@ namespace YoutubeCollector {
|
|||||||
|
|
||||||
signal_hub.exit_yt_search_mode.connect(() => {
|
signal_hub.exit_yt_search_mode.connect(() => {
|
||||||
add_buttons_revealer.set_reveal_child(true);
|
add_buttons_revealer.set_reveal_child(true);
|
||||||
controls_revealer.set_reveal_child(true);
|
//controls_revealer.set_reveal_child(true);
|
||||||
exit_yt_search_mode_revealer.set_reveal_child(false);
|
exit_yt_search_mode_revealer.set_reveal_child(false);
|
||||||
action_bar.set_margin_start(0);
|
action_bar.set_margin_start(0);
|
||||||
});
|
});
|
||||||
@@ -326,7 +326,18 @@ namespace YoutubeCollector {
|
|||||||
|
|
||||||
private void load_music(Adw.StatusPage page, PlaylistObject playlist) {
|
private void load_music(Adw.StatusPage page, PlaylistObject playlist) {
|
||||||
Adw.Clamp clamp = new Adw.Clamp();
|
Adw.Clamp clamp = new Adw.Clamp();
|
||||||
|
Gtk.Box playlist_options = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 5);
|
||||||
Gtk.ListBox content = new Gtk.ListBox();
|
Gtk.ListBox content = new Gtk.ListBox();
|
||||||
|
var options_button = new Gtk.MenuButton();
|
||||||
|
options_button.set_icon_name("open-menu-symbolic");
|
||||||
|
|
||||||
|
var options_menu = new Menu();
|
||||||
|
options_menu.append("Open Folder", "app.open_playlist_folder");
|
||||||
|
options_menu.append("Export Folder", "app.export_playlist_folder");
|
||||||
|
|
||||||
|
options_button.set_menu_model(options_menu);
|
||||||
|
playlist_options.append(options_button);
|
||||||
|
options_button.add_css_class("flat");
|
||||||
/*foreach (string i in settings.get_strv(playlist_name)) {
|
/*foreach (string i in settings.get_strv(playlist_name)) {
|
||||||
if (i != "") {
|
if (i != "") {
|
||||||
content.append(new MusicListRow(i));
|
content.append(new MusicListRow(i));
|
||||||
@@ -346,7 +357,10 @@ namespace YoutubeCollector {
|
|||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
clamp.child = content;
|
Gtk.Box total_content = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
|
||||||
|
total_content.append(playlist_options);
|
||||||
|
total_content.append(content);
|
||||||
|
clamp.child = total_content;
|
||||||
page.child = clamp;
|
page.child = clamp;
|
||||||
content.hexpand = true;
|
content.hexpand = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
namespace YoutubeCollector {
|
||||||
|
|
||||||
|
public class MediaPlayerPopup : Adw.Dialog {
|
||||||
|
|
||||||
|
private PlaylistObject working_playlist;
|
||||||
|
private PlaylistItem current_item;
|
||||||
|
|
||||||
|
private Adw.Carousel carousel = new Adw.Carousel();
|
||||||
|
|
||||||
|
private Gee.HashSet<Gtk.Widget> pages = new Gee.HashSet<Gtk.Widget>();
|
||||||
|
|
||||||
|
public MediaPlayerPopup (PlaylistObject working_playlist, PlaylistItem current_item) {
|
||||||
|
this.working_playlist = working_playlist;
|
||||||
|
this.current_item = current_item;
|
||||||
|
initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
construct {
|
||||||
|
|
||||||
|
var header_bar = new Adw.HeaderBar();
|
||||||
|
|
||||||
|
var toolbar_view = new Adw.ToolbarView();
|
||||||
|
toolbar_view.add_top_bar(header_bar);
|
||||||
|
|
||||||
|
var clamp = new Adw.Clamp();
|
||||||
|
clamp.set_child(carousel);
|
||||||
|
toolbar_view.set_content(clamp);
|
||||||
|
set_child(toolbar_view);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initialize() {
|
||||||
|
working_playlist.items.foreach ((i) => {
|
||||||
|
if (i != current_item) {
|
||||||
|
generate_empty_page(i);
|
||||||
|
} else {
|
||||||
|
generate_page(i);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void generate_empty_page(PlaylistItem item) {
|
||||||
|
var box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 5);
|
||||||
|
var media_player = new Gtk.Video();
|
||||||
|
box.append(media_player);
|
||||||
|
carousel.append(box);
|
||||||
|
}
|
||||||
|
|
||||||
|
// VERY BIG TODO: replace this with GTK MEDIA STREAM, it is just better than gstreamer and this gtkvideo whatever slow crap
|
||||||
|
|
||||||
|
private void generate_page(PlaylistItem item) {
|
||||||
|
var box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 5);
|
||||||
|
var media_player = new Gtk.Video();
|
||||||
|
File file = File.new_build_filename(Environment.get_user_data_dir(), "com.liyaowhen.YoutubeCollector", working_playlist.name, item.file);
|
||||||
|
flood_page.begin(media_player, file);
|
||||||
|
box.append(media_player);
|
||||||
|
carousel.append(box);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void flood_page (Gtk.Video media_player, File file) {
|
||||||
|
media_player.autoplay = false;
|
||||||
|
media_player.set_file(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,9 @@ namespace YoutubeCollector {
|
|||||||
public PlaylistItem item;
|
public PlaylistItem item;
|
||||||
private PlaylistObject playlist;
|
private PlaylistObject playlist;
|
||||||
|
|
||||||
|
private static AppInfo? video_preview_app = null;
|
||||||
|
private static string? video_content_type = null;
|
||||||
|
|
||||||
private Gee.HashSet<Gtk.Widget> playlist_widgets = new Gee.HashSet<Gtk.Widget>();
|
private Gee.HashSet<Gtk.Widget> playlist_widgets = new Gee.HashSet<Gtk.Widget>();
|
||||||
|
|
||||||
public MusicListRow (PlaylistItem _item, PlaylistObject playlist) {
|
public MusicListRow (PlaylistItem _item, PlaylistObject playlist) {
|
||||||
@@ -37,7 +40,9 @@ namespace YoutubeCollector {
|
|||||||
play_button.add_css_class("flat");
|
play_button.add_css_class("flat");
|
||||||
|
|
||||||
play_button.clicked.connect(() => {
|
play_button.clicked.connect(() => {
|
||||||
if (AppController.song_controls.current_item != item) {
|
/*var popup = new MediaPlayerPopup(playlist, item);
|
||||||
|
popup.present(this);*/
|
||||||
|
/*if (AppController.song_controls.current_item != item) {
|
||||||
AppController.song_controls.change_item(item, playlist);
|
AppController.song_controls.change_item(item, playlist);
|
||||||
play_button.icon_name = "media-playback-pause-symbolic";
|
play_button.icon_name = "media-playback-pause-symbolic";
|
||||||
Timeout.add(1, () => {
|
Timeout.add(1, () => {
|
||||||
@@ -54,7 +59,22 @@ namespace YoutubeCollector {
|
|||||||
} else if (!AppController.song_controls.isPlaying) {
|
} else if (!AppController.song_controls.isPlaying) {
|
||||||
AppController.song_controls.play();
|
AppController.song_controls.play();
|
||||||
play_button.icon_name = "media-playback-pause-symbolic";
|
play_button.icon_name = "media-playback-pause-symbolic";
|
||||||
|
}*/
|
||||||
|
File file = File.new_build_filename(Environment.get_user_data_dir(), "com.liyaowhen.YoutubeCollector", playlist.name, item.file);
|
||||||
|
AppInfo? app = null;
|
||||||
|
file.query_default_handler_async.begin(1, null, (res, a) => {
|
||||||
|
try {
|
||||||
|
app = file.query_default_handler_async.end(a);
|
||||||
|
if (app != null) {
|
||||||
|
var l = new List<File>();
|
||||||
|
l.append(file);
|
||||||
|
app.launch(l, null);
|
||||||
}
|
}
|
||||||
|
} catch (Error e) {
|
||||||
|
print(e.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
append(play_button);
|
append(play_button);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using Gst;
|
|||||||
TODO: Work towards removing song controller entirely, instead use external apps to preview the files instead
|
TODO: Work towards removing song controller entirely, instead use external apps to preview the files instead
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
namespace YoutubeCollector {
|
namespace YoutubeCollector {
|
||||||
public class SongControls : Gtk.Box {
|
public class SongControls : Gtk.Box {
|
||||||
|
|
||||||
@@ -178,3 +179,4 @@ namespace YoutubeCollector {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
Reference in New Issue
Block a user