Skip to content
Extraits de code Groupes Projets
Sélectionner une révision Git
  • c2fbca5544468b560a32bff0a97a70ca4fbdf4f0
  • main par défaut protégée
  • renovate/eslint-monorepo
  • renovate/sveltejs-kit-2.x-lockfile
  • renovate/msgpackr-1.x-lockfile
  • renovate/gql.tada-1.x-lockfile
  • renovate/vite-5.x-lockfile
  • renovate/tailwindcss-monorepo
  • renovate/svelte-check-3.x-lockfile
  • renovate/svelte-4.x-lockfile
  • renovate/prettier-plugin-tailwindcss-0.x-lockfile
  • renovate/dotenv-cli-7.x-lockfile
  • renovate/autoprefixer-10.x-lockfile
  • renovate/eslint-9.x-lockfile
  • renovate/sveltejs-vite-plugin-svelte-3.x-lockfile
  • renovate/sveltejs-adapter-node-5.x-lockfile
  • renovate/node-22.x
  • renovate/arise-aidc-sveltekit-0.x
18 résultats

+page.server.ts

Blame
  • spotify.pm 926 o
    package PlayBot::sites::spotify;
    
    use strict;
    use warnings;
    
    use LWP::UserAgent;
    use JSON;
    use FindBin;
    
    my $conf;
    my $endpoint = "https://api.spotify.com/v1/tracks/";
    
    sub regex
    {
        return qr#(?:^|[^!])https?://(open|play).spotify.com/track/([a-zA-Z0-9_-]+)#;
    }
    
    sub get {
        shift;
    	my $id = shift;
    	
        my $ua = LWP::UserAgent->new(
            timeout     => 30,
            env_proxy   => 1,
        );
    	my $response = $ua->get($endpoint
            .$id);
    	die($response->status_line) unless ($response->is_success);
    
    	my $content = decode_json($response->decoded_content);
    
    #    die "video not found" if (not scalar @{ $content->{items} });
        
        my %infos;
    
        $infos{'title'} = $content->{'name'};
        $infos{'duration'} = $content->{'duration_ms'} / 1000;
    	$infos{'site'} = 'spotify';
        $infos{'url'} = 'https://open.spotify/track/'.$id;
        $infos{'author'} = $content->{'artists'}->[0]->{'name'};
    
    	return %infos;
    }
    
    1;