diff --git a/shard.yml b/shard.yml index e370994..cdfd654 100644 --- a/shard.yml +++ b/shard.yml @@ -12,6 +12,6 @@ dependencies: m3u8: github: akiicat/m3u8 -crystal: 1.4.0 +crystal: 1.6.2 license: AGPL diff --git a/src/base.cr b/src/base.cr new file mode 100644 index 0000000..5415e3b --- /dev/null +++ b/src/base.cr @@ -0,0 +1,7 @@ +# This is the base functionality code interchangeable between cli and server program +module Base + VERSION = "0.1.0" + + # TODO: Put your code here + print("Hello world") +end diff --git a/src/bridges/connector.cr b/src/bridges/connector.cr new file mode 100644 index 0000000..c01dc76 --- /dev/null +++ b/src/bridges/connector.cr @@ -0,0 +1,7 @@ +# TODO: Write documentation for `Playper` +module API_Connect + VERSION = "0.1.0" + + # TODO: Put your code here + print("Hello world") + end diff --git a/src/bridges/m3u8.cr b/src/bridges/m3u8.cr new file mode 100644 index 0000000..efb6998 --- /dev/null +++ b/src/bridges/m3u8.cr @@ -0,0 +1,18 @@ +# M3U8 +# Input +# swapper.cr +# Output +require "m3u8" + +module m3u8 + include M3U8 + # Read Playlist + file = File.read "spec/playlists/master.m3u8" + playlist = Playlist.parse(file) + playlist.master? # => true + + # Generate playlist/stream + playlist = Playlist.new + playlist.items << SegmentItem.new(duration: 10.991, segment: "test_01.ts") + playlist.to_s +end diff --git a/src/bridges/metadata.cr b/src/bridges/metadata.cr new file mode 100644 index 0000000..d5ba98c --- /dev/null +++ b/src/bridges/metadata.cr @@ -0,0 +1,9 @@ +# This is the Musicbrainz API +# API for collecting and connecting to metadata providers as well as parsing that +# And return it for other functions +module Metadata + VERSION = "0.1.0" + + # TODO: Put your code here + print("Hello world") +end diff --git a/src/bridges/spotify.cr b/src/bridges/spotify.cr new file mode 100644 index 0000000..bcfa130 --- /dev/null +++ b/src/bridges/spotify.cr @@ -0,0 +1,11 @@ +# Spotify API interactions +# GET +# POST +# Need to read deep into the API and make it the most user friendly possible. + +module API_Spotify + VERSION = "0.1.0" + + # TODO: Put your code here + print("Hello world") + end diff --git a/src/bridges/xspf.cr b/src/bridges/xspf.cr new file mode 100644 index 0000000..db79efd --- /dev/null +++ b/src/bridges/xspf.cr @@ -0,0 +1,91 @@ +require "xml" +# Interacting with XSPF playlist files used by clementine +# XSPF +# Input +# swapper.cr +# Output + +module API_XSPF + VERSION = "0.1.0" + + # TODO: Put your code here +# +# +# +# + +# /media/Plex/Music/11. KOMM,SUSSER TOD(M-10 DIRECTOR'S EDIT.VERSION).flac +# 11. KOMM,SUSSER TOD(M-10 DIRECTOR'S EDIT.VERSION) +# 463000 +# /media/Plex/Music/692b6cb2e35e18c27b32e0632a07dd47.sync-conflict-20220110-215510-IRXNWES.png +# +# + +#Read FROM +file = File.new("Playlist5.xspf") +content = file.gets_to_end +filez = "Playlist5.xspf" +#puts content +xml_file = XML::Reader.new(content) +file.close + #def self.new(io : IO, options : XML::ParserOptions = XML::ParserOptions.default) end + + #files = File.read("path/to/doc.xml") + #xml = XML.parse(files) + #node = xml.xpath_node("//foo/@ID") + #node.text + + reader = Char::Reader.new("aƩ") + puts "#{typeof(xml_file)} <- Tipo de XML" + #puts "IO READTEST #{xml_file.read}" + puts "IO TEST #{xml_file.inspect}" + #puts "IO READ INNER #{xml_file.read_inner_xml}" + puts "IO DEPTH #{xml_file.depth}" + puts "IO READ OUTER #{xml_file.read_outer_xml}" + #xml_file = XML.Reader.new(io : IO, options : XML::ParserOptions = XML::ParserOptions.default) + #def self.parse(io : IO, options : ParserOptions = ParserOptions.default) : Node + #end + + xml = <<-XML + + Jane + Doe + + + Albert + Doe + + XML + + document = XML.parse(xml) # : XML::Node + person = document.first_element_child # : XML::Node? + persons = document.children # XML::NodeSet + if person + puts person["id"] # "1" : String? + + puts typeof(person.children) # XML::NodeSet + person.children.select(&.element?).each do |child| # Select only element children + #document.children.select(&.element?).each do |child| # Select only element children + #puts child["id"] + puts typeof(child) # XML::Node + puts child.name # firstname : String + puts child.content # Jane : String? + end + persona = person.next + puts "#{typeof(person)} <- Tipo de person" + puts "#{typeof(persona)} <- Tipo de persona " + puts "#{typeof(persons)} <- Tipo de persons" + #puts persona["id"] + end + +#Write TO + string = XML.build(indent: " ") do |xml| + xml.element("person", id: 3) do + xml.element("firstname") { xml.text "Jean" } + xml.element("lastname") { xml.text "D'Arc" } + end + end + + + +end diff --git a/src/bridges/youtube.cr b/src/bridges/youtube.cr new file mode 100644 index 0000000..6559172 --- /dev/null +++ b/src/bridges/youtube.cr @@ -0,0 +1,3 @@ +# Youtube API +# Get +# Post diff --git a/src/database.cr b/src/database.cr index ff92a01..49aaef8 100644 --- a/src/database.cr +++ b/src/database.cr @@ -1,2 +1,10 @@ +# TODO: Write documentation for `Playper` # Here everything for supporting persistent storage will be saved # Being it postgresql or sqlite + +module Database + VERSION = "0.1.0" + + # TODO: Put your code here + print("Hello world") + end diff --git a/src/playper.cr b/src/playper.cr index 2b0cd20..188b81d 100644 --- a/src/playper.cr +++ b/src/playper.cr @@ -4,6 +4,6 @@ module Playper VERSION = "0.1.0" # TODO: Put your code here - + print("Hello world") end diff --git a/src/reader_input.cr b/src/reader_input.cr index 89a866d..d27a32c 100644 --- a/src/reader_input.cr +++ b/src/reader_input.cr @@ -1,4 +1,6 @@ require "colorize" +require "./hosts/*" + # This is a bit of a metaclass for now # Its going to be abstract class for input also working with cases diff --git a/src/swapper.cr b/src/swapper.cr index 831cd38..c492718 100644 --- a/src/swapper.cr +++ b/src/swapper.cr @@ -1,4 +1,3 @@ - # Actual swaping of playlist from one format to another # Different cases for different hosts # Make use of the metadata class for concurrency diff --git a/src/tryerror/help.cr b/src/tryerror/help.cr new file mode 100644 index 0000000..7d9d9dd --- /dev/null +++ b/src/tryerror/help.cr @@ -0,0 +1,49 @@ +require "option_parser" +require "colorize" + +the_beatles = [ + "John Lennon", + "Paul McCartney", + "George Harrison", + "Ringo Starr", +] + +say_hi_to = "" +OptionParser.parse do |parser| + parser.banner = "These are the options for playper-cli: " + #parser.banner = "#{"The Beatles"App" + + parser.on "-v", "--version", "Show version" do + puts "version 0.1.0" + exit + end + parser.on "-h", "--help", "Show help" do + puts parser + exit + end + parser.on "-sp", "--spotify", "Show version" do + puts "Make use of spotify info." + exit + end + parser.on "-g NAME", "--goodbye_hello=NAME", "Say hello to whoever you want" do |name| + say_hi_to = name + end + # Exception Handling + parser.missing_option do |option_flag| + STDERR.puts "ERROR: #{option_flag} is missing something.".colorize(:green).on(:black) + STDERR.puts "" + STDERR.puts parser + exit(1) + end + parser.invalid_option do |option_flag| + STDERR.puts "ERROR: #{option_flag} is not a valid option.".colorize(:yellow).on(:black) + STDERR.puts parser + exit(1) + end + #puts parser +end + +unless say_hi_to.empty? + puts "" + puts "You say goodbye, and #{the_beatles.sample} says hello to #{say_hi_to}!" +end