revisions + http client json gotten

This commit is contained in:
Nimble 2023-01-29 21:58:13 -06:00
parent b1950d4610
commit 3e42f24485
7 changed files with 63 additions and 25 deletions

View File

@ -11,4 +11,13 @@ Rosetta Stone for musical Playlists.
- [ ] First version is going to be terminal only no need to authentication and it maybe ephimeral meaning the playlist changed won't be stored, it will only swap or appear in a different platform
- [ ] Authentication service (not necesary)
- [ ] Database management
- [ ] GUI
- [ ] GUI
- [ ] We have the Spotify JSON we can use that for playing for now
- [ ] Convert it to Array/List
- [ ] Save it as XSPF
- [ ] Save it as m3u
- [ ] Send it to Youtube
- [ ] Send it to last.fm
- [ ] Send it to libre.fm
- [ ] Send it to music.brainz
- [ ] Play with the metadata so we have a solid list

View File

@ -1,7 +1,31 @@
# TODO: Write documentation for `Playper`
module API_Connect
VERSION = "0.1.0"
# This is the piece of tool that will do the queries.
# It needs values for input maybe could only be made into a function.
# Where do we give it the arguments?
# Will it be embed on the bridges or will
# This will be a metamodule or an abstract class and it will accomodate to all cases
# TODO: Put your code here
print("Hello world")
require "http/client"
module APIConnect
extend self
# params = URI::Params.encode({"author" => "John Doe", "offset" => "20"}) # => "author=John+Doe&offset=20"
# HTTP::Client.get URI.new("https", "novoa.nagoya", query: params) do |response|
# puts response.status_code # => 200
# puts response.body_io.gets # => "<!doctype html>"
# end
def requestGet
# The logic of this shit works but I am going to steal code from irs
# The code from IRS does not enable an Authorization Workflow for spotify
baseUrl = "https://api.spotify.com/v1/me/playlists"
key = "BQBemjJEL0k8Wg2J6Mi7pg-vKCA1SFDy06JVv8oeXck98P4a660BpF7ScpVrCZzMEGmvBo0lunmfucakBTSUeNVAJaXrs56pdFQjicQN9ueW2GVGo68GZqk06FZJOOYZHqmhomwbZ28FOGiYfosN_1GysjYQKOHnu01efGTsuzFCE2yCC7s9tJNpow"
params = "?key=#{key}"
response = HTTP::Client.get(baseUrl, HTTP::Headers{"Authorization:" => key, "Accept:" => "application/json", "Content-Type:" => "application/json"
})
puts response.to_s
puts response.body
puts response.status_code
end
def requestDelete
end
end

View File

@ -5,5 +5,5 @@ module Metadata
VERSION = "0.1.0"
# TODO: Put your code here
print("Hello world")
print("Module Metadata")
end

View File

@ -2,10 +2,17 @@
# GET
# POST
# Need to read deep into the API and make it the most user friendly possible.
# USE THIS ---> Authorization Code Flow
# Use irs to parse the absolutely shitty json, specially the part where it gets songs from playlists
module API_Spotify
VERSION = "0.1.0"
# TODO: Put your code here
print("Hello world")
require "json"
module APISpotify
#This should be an input/variable or a direct response from a request to Spotify
json = File.open("spec/files/spotify-user-playlists.json") do |file|
JSON.parse(file)
end
end
#puts json

View File

@ -1,2 +0,0 @@
# API for collecting and connecting to metadata providers as well as parsing that
# And return it for other functions

View File

@ -20,17 +20,12 @@
# HelpTest
# end
require "./tryerror/*"
require "./reader_input.cr"
require "./swapper.cr"
module Playper
include ReaderInput
include HelpTest
include APIConnect
include APISpotify
VERSION = "0.1.0"
# TODO: Put your code here
puts "Hello world!"
#ReaderInput.cli_input #runs cli_input from ReaderInput
HelpTest
APIConnect.requestGet
end

View File

@ -1,8 +1,13 @@
# Actual swaping of playlist from one format to another
# Different cases for different hosts
# Make use of the metadata class for concurrency
# This is the main an crucial part of the problem, expected input in one format and output in the other.
# As such variables of the input and output are required, metadata (type/platform) and data (Actual playlist) of it.
# Here all the data has to be abstracted to only have an array containing a "ultimate list" that is interchangeable depending on the output
# We need to check the APIs first to see how to proceed best with the issue
require "./bridges/*"
class Swapper
extend Reader_Input
reader = Reader_Input.cli_input
puts "The Beatles are singing: #{"🎵#{reader.lyrics}🎶🎸🥁".colorize.mode(:blink)}"
end