spot2txt

Export Spotify Playlist Listings as Plaintext
git clone git://git.alexkarle.com.com/spot2txt
Log | Files | Refs | README

commit c74bf0caaf4512c90fff60ea2900f8651cc3fe02 (patch)
parent a84d360c36f3466a39f86846f939096d5b27a699
Author: Alex Karle <alex@alexkarle.com>
Date:   Mon,  3 Feb 2025 21:40:42 -0500

Add Auth Code up until "code" is returned

Diffstat:
MREADME | 7+++++++
Aserver.pl | 44++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/README b/README @@ -1,3 +1,10 @@ # spotilist Spotify Playlist Exporter + +## Dependencies + +On OpenBSD 7.6 the following packages are required: + +- p5-libwww +- p5-LWP-Protocol-https diff --git a/server.pl b/server.pl @@ -0,0 +1,44 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +use Mojolicious::Lite; + +my $CLIENT_ID = $ENV{SPOTIFY_CLIENT_ID}; +my $CLIENT_SECRET = $ENV{SPOTIFY_CLIENT_SECRET}; +if (!$CLIENT_ID || !$CLIENT_SECRET) { + die "Spotify Env Vars not set\n"; +} + +my $AUTH_URL = "https://accounts.spotify.com/authorize" + . "?client_id=$CLIENT_ID" + . "&response_type=code" + . "&redirect_uri=http://localhost:3000/auth" + . "&scope=playlist-read-private&playlist-read-collaborative" + . "&state=" . int(rand() * 100); + +get '/' => sub { + my $c = shift; + $c->render( + template => "index", + AUTH_URL => $AUTH_URL, + ); +}; + +get 'auth' => sub { + my $c = shift; + $c->render(text => "Your code is:\n" . $c->param("code")); +}; + +app->start; + +__DATA__ + +@@index.html.ep +<h1>Spotify Playlist Exporter</h1> +<p>Hello and welcome to the Spotify Playlist Exporter!</p> +<p>To start, first log in to Spotify and authorize this +app by clicking the link below:</p> +<a href=<%= $AUTH_URL %>> +Authorize +</a>