line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::LinkEmbedder::Link::Music::Spotify; |
2
|
1
|
|
|
1
|
|
404
|
use Mojo::Base 'Mojolicious::Plugin::LinkEmbedder::Link::Music'; |
|
1
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
4
|
|
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
|
1
|
|
sub provider_name {'Spotify'} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub pretty_url { |
16
|
0
|
|
|
0
|
1
|
|
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
|
1
|
|
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; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=encoding utf8 |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 NAME |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Mojolicious::Plugin::LinkEmbedder::Link::Music::Spotify - Spotify link |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 DESCRIPTION |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
L |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
This class inherit from L. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 media_id |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Returns a normalized spotify link. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 provider_name |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Returns "Spotify". |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 METHODS |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 pretty_url |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Returns a L link with L. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 to_embed |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Returns the HTML code for an iframe embedding this movie. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 AUTHOR |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Marcus Ramberg |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=cut |