This repository has been archived by the owner on Jul 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f3d1a6a
commit 9a371dd
Showing
33 changed files
with
966 additions
and
352 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# Import cache | ||
.import/ | ||
*.import | ||
|
||
# Binaries | ||
bin/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
extends Node | ||
var Player | ||
var Config = ConfigFile.new() | ||
var Config := ConfigFile.new() | ||
|
||
func _ready(): | ||
Config.load("user://cello.cfg") |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
extends HBoxContainer | ||
class_name Album | ||
var title: String setget , get_title | ||
var tracks_len: int setget , get_tracks_len | ||
var playlist_path | ||
|
||
func get_tracks() -> Array: | ||
return $TracksParent/Tracks.get_children() | ||
|
||
func get_title() -> String: | ||
return $VBoxContainer/PanelContainer/Title.text | ||
|
||
func get_tracks_len() -> int: | ||
return $TracksParent/Tracks.get_child_count() | ||
|
||
func get_art() -> Texture: | ||
return $VBoxContainer/Art.texture | ||
|
||
var Track = preload("res://General/Library/Track.tscn") | ||
func add_track(p: String, zip = null): | ||
var track = Track.instance() | ||
track.path = p | ||
if zip: | ||
track.zip_source = zip | ||
$TracksParent/Tracks.add_child(track) | ||
|
||
onready var title_n = $VBoxContainer/PanelContainer/Title | ||
onready var tracks_n = $TracksParent/Tracks | ||
const MaximumTracksInColumn = 7.0 # ???? | ||
# Oh, its the maximum no of vertical tracks in the popout | ||
func _ready(): | ||
var meta: TagFile = tracks_n.get_child(0).metadata | ||
var art = meta.get_album_art() | ||
var tracks = get_tracks() | ||
var total_tracks = tracks.size() | ||
var columns = ceil(total_tracks / MaximumTracksInColumn) | ||
tracks_n.columns = columns if columns > 1 else 1 | ||
|
||
if title: | ||
title_n.text = title | ||
else: | ||
title_n.text = meta.get_album() | ||
if art: | ||
$VBoxContainer/Art.texture.set_data(art) | ||
|
||
for i in range(0, total_tracks): | ||
var track = tracks[i] | ||
track.connect("pressed", Global.Player, "play_album", [ tracks, i, $VBoxContainer/Art.texture ]) | ||
|
||
func get_drag_data(_position): | ||
# TODO: Get a preview working. | ||
return self | ||
|
||
func _on_Album_gui_input(event: InputEvent): | ||
if event is InputEventMouseButton and event.pressed == true and event.button_index == BUTTON_LEFT: | ||
var is_visible = $TracksParent.visible | ||
if not is_visible: | ||
$TracksParent.visible = true | ||
else: | ||
$TracksParent.visible = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
extends GridContainer | ||
const Album = preload("res://General/Library/Album.tscn") | ||
|
||
# TODO: Replace the _zip methods | ||
# TODO: Make functions zip path aware | ||
|
||
func parse_m3u(path: String) -> Array: | ||
var f := File.new() # File will only be read once | ||
f.open(path, File.READ) | ||
var tracks := [] | ||
var line := f.get_line() | ||
if line != "#EXTM3U": | ||
return tracks # not a valid file | ||
|
||
var dir = path.get_base_dir() | ||
while line != "": | ||
|
||
if not line.begins_with("#"): | ||
if line.is_abs_path() and f.file_exists(line): | ||
tracks.push_back(line) | ||
elif line.is_rel_path() and f.file_exists(dir+'/'+line): | ||
tracks.push_back(dir+'/'+line) | ||
line = f.get_line() | ||
|
||
f.close() | ||
return tracks | ||
func parse_m3u_zip(source: ZIPReader, path: String, zip_path: String) -> Array: | ||
var content = source.read_file(path).get_string_from_utf8().split('\n', false) | ||
var tracks := [] | ||
if content[0] != "#EXTM3U": | ||
return tracks | ||
|
||
# TODO: Check that file exists | ||
for line in content: | ||
if not line.begins_with("#"): | ||
tracks.push_back([zip_path+"::"+line, source]) | ||
|
||
return tracks | ||
|
||
func parse_playlist_file(path: String): | ||
var f := File.new() | ||
f.open(path, File.READ) | ||
var a: Album = Album.instance() | ||
a.playlist_path = path | ||
var line := f.get_line() | ||
while line != "": | ||
if f.file_exists(line): | ||
a.add_track(line) | ||
line = f.get_line() | ||
f.close() | ||
a.title = path.get_file().replace(".playlist.txt", "") | ||
add_child(a) | ||
|
||
func new_album(dirn): | ||
var dir = Directory.new() | ||
dir.open(dirn) | ||
|
||
dir.list_dir_begin(true, true) | ||
var tracks: PoolStringArray = [] | ||
var name = dir.get_next() | ||
while name != "": | ||
name = dirn + '/' + name | ||
var ext = name.get_extension() | ||
if ext == 'flac' or ext == 'mp3' or ext == 'ogg': | ||
tracks.push_back(name) | ||
# if you find a index file, use it & reset | ||
elif (ext == 'm3u' or ext == 'm3u8'): | ||
tracks = parse_m3u(name) | ||
break | ||
elif name.ends_with('.playlist.txt'): | ||
parse_playlist_file(name) | ||
return | ||
|
||
name = dir.get_next() | ||
|
||
if tracks.size() > 0: | ||
var a: Album = Album.instance() | ||
for track in tracks: | ||
a.add_track(track) | ||
self.add_child(a) | ||
|
||
func new_album_from_zip(path: String): | ||
var reader: ZIPReader = ZIPReader.new() | ||
reader.open(path) | ||
|
||
var tracks = [] | ||
for file in reader.get_files(): | ||
var ext = file.get_extension() | ||
if ext == 'flac' or ext == 'ogg' or ext == 'mp3': | ||
tracks.push_back(file) | ||
elif (ext == 'm3u8' or ext == 'm3u'): | ||
tracks = parse_m3u_zip(reader, file, path) | ||
break | ||
if tracks.size() > 0: | ||
var a: Album = Album.instance() | ||
for track in tracks: | ||
a.add_track(track[0], track[1]) | ||
self.add_child(a) | ||
|
||
var ts := [] | ||
var album_size: int | ||
func _ready() -> void: | ||
var dirs: PoolStringArray = Global.Config.get_value("general", "search-dirs", [ OS.get_system_dir(OS.SYSTEM_DIR_MUSIC) ]) | ||
var dir := Directory.new() | ||
var unsorted: Album = Album.instance() | ||
album_size = unsorted.rect_size[0] | ||
unsorted.title = "Unsorted" | ||
for dirn in dirs: | ||
if dir.open(dirn) != OK: | ||
continue | ||
var _err = dir.list_dir_begin(true, true) | ||
var name = dir.get_next() | ||
while name != "": | ||
name = dirn + '/' + name | ||
var ext = name.get_extension() | ||
if dir.current_is_dir(): | ||
var t = Thread.new() | ||
t.start(self, "new_album", name) | ||
ts.push_back(t) | ||
elif ext == 'flac' or ext == 'mp3' or ext == 'ogg': | ||
unsorted.add_track(name) | ||
elif ext == 'zip': | ||
var t = Thread.new() | ||
t.start(self, "new_album_from_zip", name) | ||
ts.push_back(t) | ||
elif name.ends_with('.playlist.txt'): | ||
parse_playlist_file(name) | ||
#var t = Thread.new() | ||
#t.start(self, "parse_playlist_file", name) | ||
|
||
name = dir.get_next() | ||
if unsorted.tracks_len > 1: | ||
self.add_child(unsorted) | ||
|
||
_resized() | ||
|
||
export(NodePath) onready var size_n = get_node(size_n) as Node | ||
func _resized(): | ||
columns = floor(size_n.rect_size[0] / album_size) | ||
|
||
func _exit_tree(): | ||
for t in ts: | ||
t.wait_to_finish() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
extends Button | ||
class_name AlbumTrack | ||
|
||
export var path: String #setget _, format_path | ||
var zip_source: ZIPReader | ||
var metadata := TagFile.new() | ||
|
||
func _ready(): | ||
if not zip_source: | ||
metadata.open_path(path) | ||
else: | ||
metadata.open_bytes(zip_source.read_file(path.split("::")[1])) | ||
self.hint_tooltip = metadata.get_title() | ||
#metadata.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
extends Tree | ||
|
||
export(NodePath) onready var Title = get_node(Title) as LineEdit | ||
export(NodePath) onready var Runtime = get_node(Runtime) as Label | ||
|
||
func can_drop_data(_position, data): | ||
return data is TreeItem | ||
|
||
func update_runtime(): | ||
#print(total_runtime) | ||
var minutes = total_runtime/60.0 | ||
Runtime.text = "Runtime: %.0fm%.0fs" % [ minutes, (minutes-int(minutes))*10 ] | ||
|
||
onready var root = create_item() | ||
#var total_items = 0 | ||
var total_runtime = 0 | ||
func drop_data(_position, data: TreeItem): | ||
#total_items += 1 | ||
var i := create_item(root) | ||
#i.set_text(0, String(total_items)) | ||
i.set_tooltip(0, data.get_tooltip(0)) | ||
i.set_text(0, data.get_text(0)) | ||
var metadata: TagFile = data.get_metadata(0) | ||
i.set_text(1, metadata.get_album()) | ||
i.set_metadata(0, data.get_tooltip(0)) | ||
total_runtime += metadata.get_length_in_seconds() | ||
update_runtime() | ||
|
||
func _ready(): | ||
Title.text = "New Album %x" % randi() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
extends HBoxContainer | ||
|
||
export(NodePath) onready var Playlists = get_node(Playlists) | ||
onready var tree: Tree = $Sidebar/Tree | ||
|
||
export var edit_texture: Texture | ||
func _ready(): | ||
var root = tree.create_item() | ||
for album in Playlists.get_children(): | ||
album = album as Album | ||
var item = tree.create_item(root) | ||
item.set_text(0, album.title) | ||
|
||
for track in album.get_tracks(): | ||
var child = tree.create_item(item) | ||
child.set_text(0, track.hint_tooltip) | ||
child.set_tooltip(0, track.path) | ||
child.set_metadata(0, track.metadata) | ||
|
||
if album.playlist_path: | ||
item.set_metadata(0, album.playlist_path) | ||
item.add_button(0, edit_texture, -1, false, "Edit Playlist") | ||
|
||
onready var playlist_dir: String = Global.Config.get_value("general", "playlist-save-dir", OS.get_system_dir(OS.SYSTEM_DIR_MUSIC)+"/Playlists") | ||
onready var playlist_path = playlist_dir+'/'+$VBoxContainer/PanelContainer/Preview/Title.text+'.playlist.txt' | ||
|
||
func _on_Save_pressed(): | ||
Directory.new().make_dir_recursive(playlist_path.get_base_dir()) | ||
var f := File.new() | ||
f.open(playlist_path, File.WRITE) | ||
var item = $VBoxContainer/Main.get_root().get_children() | ||
while item != null: | ||
f.store_line(item.get_metadata(0)) | ||
item = item.get_next() | ||
f.close() | ||
|
||
func _on_Title_text_changed(new_text): | ||
playlist_path = playlist_dir+'/'+new_text+'.playlist.txt' |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
extends Tree | ||
|
||
func get_drag_data(_position): | ||
set_drop_mode_flags(DROP_MODE_DISABLED) | ||
|
||
var selected: TreeItem = get_selected() | ||
|
||
if not selected.get_tooltip(0).length() > 0: | ||
return | ||
|
||
var preview = Label.new() | ||
preview.text = selected.get_text(0) | ||
set_drag_preview(preview) | ||
|
||
return selected | ||
|
||
func can_drop_data(_position, _data): | ||
return false | ||
|
||
export(NodePath) onready var Root = get_node(Root) as Node | ||
export(NodePath) onready var MainTree = get_node(MainTree) as Node | ||
func _on_Tree_button_pressed(item: TreeItem, column: int, id: int): | ||
var playlist_path: String = item.get_metadata(0) | ||
Root.get_node("VBoxContainer/PanelContainer/Preview/Title").text = playlist_path.get_file().replace(".playlist.txt", "") | ||
#print(Root) | ||
Root.playlist_path = playlist_path | ||
MainTree.clear() | ||
var child: TreeItem = item.get_children() | ||
while child != null: | ||
MainTree.drop_data(null, child) | ||
child = child.get_next() |
Oops, something went wrong.