line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::LinkEmbedder::Link::Music::Spotify; |
2
|
1
|
|
|
1
|
|
2346
|
use Mojo::Base 'Mojolicious::Plugin::LinkEmbedder::Link::Music'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
has media_id => sub { |
5
|
|
|
|
|
|
|
my $self = shift; |
6
|
|
|
|
|
|
|
my $path = $self->url->path; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
return join ':', spotify => "$path" if $self->url->scheme eq 'spotify'; |
9
|
|
|
|
|
|
|
return join ':', spotify => @$path if @$path == 2; |
10
|
|
|
|
|
|
|
return ''; |
11
|
|
|
|
|
|
|
}; |
12
|
|
|
|
|
|
|
|
13
|
0
|
|
|
0
|
0
|
|
sub provider_name {'Spotify'} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub pretty_url { |
16
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
17
|
0
|
|
|
|
|
|
my $url = Mojo::URL->new('https://open.spotify.com'); |
18
|
0
|
|
|
|
|
|
my $media_id = $self->media_id; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
$media_id =~ s!^spotify!!; |
21
|
0
|
|
|
|
|
|
$url->path(join '/', split ':', $media_id); |
22
|
0
|
|
|
|
|
|
$url; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub to_embed { |
26
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
27
|
0
|
0
|
|
|
|
|
my $media_id = $self->media_id or return $self->SUPER::to_embed; |
28
|
0
|
|
|
|
|
|
my %args = @_; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
0
|
|
|
|
$args{width} ||= 300; |
31
|
0
|
|
0
|
|
|
|
$args{height} ||= 80; |
32
|
0
|
|
0
|
|
|
|
$args{view} ||= 'coverart'; |
33
|
0
|
|
0
|
|
|
|
$args{theme} ||= 'white'; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
$self->_iframe( |
36
|
|
|
|
|
|
|
src => "https://embed.spotify.com/?uri=$media_id&theme=$args{theme}&view=$args{view}", |
37
|
|
|
|
|
|
|
class => 'link-embedder music-spotify', |
38
|
|
|
|
|
|
|
width => $args{width}, |
39
|
|
|
|
|
|
|
height => $args{height} |
40
|
0
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |