line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::LinkEmbedder::Link::Music::Spotify; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Mojolicious::Plugin::LinkEmbedder::Link::Music::Spotify - Spotify link |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 DESCRIPTION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
L |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
This class inherit from L. |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=cut |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
394
|
use Mojo::Base 'Mojolicious::Plugin::LinkEmbedder::Link::Music'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head2 media_id |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Returns a normalized spotify link. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head2 provider_name |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Returns "Spotify". |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=cut |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has media_id => sub { |
30
|
|
|
|
|
|
|
my $self = shift; |
31
|
|
|
|
|
|
|
my $path = $self->url->path; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
return join ':', spotify => "$path" if $self->url->scheme eq 'spotify'; |
34
|
|
|
|
|
|
|
return join ':', spotify => @$path if @$path == 2; |
35
|
|
|
|
|
|
|
return ''; |
36
|
|
|
|
|
|
|
}; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
0
|
1
|
|
sub provider_name {'Spotify'} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 METHODS |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 pretty_url |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Returns a L link with L. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub pretty_url { |
49
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
50
|
0
|
|
|
|
|
|
my $url = Mojo::URL->new('https://open.spotify.com'); |
51
|
0
|
|
|
|
|
|
my $media_id = $self->media_id; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
$media_id =~ s!^spotify!!; |
54
|
0
|
|
|
|
|
|
$url->path(join '/', split ':', $media_id); |
55
|
0
|
|
|
|
|
|
$url; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 to_embed |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Returns the HTML code for an iframe embedding this movie. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub to_embed { |
65
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
66
|
0
|
0
|
|
|
|
|
my $media_id = $self->media_id or return $self->SUPER::to_embed; |
67
|
0
|
|
|
|
|
|
my %args = @_; |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
0
|
|
|
|
$args{width} ||= 300; |
70
|
0
|
|
0
|
|
|
|
$args{height} ||= 80; |
71
|
0
|
|
0
|
|
|
|
$args{view} ||= 'coverart'; |
72
|
0
|
|
0
|
|
|
|
$args{theme} ||= 'white'; |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
$self->_iframe( |
75
|
|
|
|
|
|
|
src => "https://embed.spotify.com/?uri=$media_id&theme=$args{theme}&view=$args{view}", |
76
|
|
|
|
|
|
|
class => 'link-embedder music-spotify', |
77
|
|
|
|
|
|
|
width => $args{width}, |
78
|
|
|
|
|
|
|
height => $args{height} |
79
|
|
|
|
|
|
|
); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 AUTHOR |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Marcus Ramberg |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |