| 1 | package Music::Tag::LyricsFetcher; | ||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use strict; use warnings; use utf8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 2 | our $VERSION = '0.4101'; | |||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | # Copyright © 2008,2010 Edward Allen III. Some rights reserved. | ||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||
| 7 | # You may distribute under the terms of either the GNU General Public | ||||||||||||||||||||||||||||
| 8 | # License or the Artistic License, as specified in the README file. | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use Lyrics::Fetcher; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use base qw(Music::Tag::Generic); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 1 | ▶ | sub default_options {{ | ||||||||||||||||||||||||||
|
Subroutine
default_options: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 14 | 1 | 'lyricsoverwrite' => 0, | |||||||||||||||||||||||||||
| 15 | 'lyricsfetchers' => undef, | ||||||||||||||||||||||||||||
| 16 | }} | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 1 | ▶ | sub get_tag { | ||||||||||||||||||||||||||
|
Subroutine
get_tag: called CC=7 SCAR=27.7
Pod
documented
| |||||||||||||||||||||||||||||
| 19 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 20 | 1 | ▶ | unless ( $self->info->has_data('artist') && $self->info->has_data('title') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->info->has_data("artist") and $self->info->has_data("title")
MC/DC0%0/2
$self->info->has_data("artist") and $self->info->has_data("title")
$self->info->has_data("artist")
$self->info->has_data("title")
Truth table33%1/3
A and B
A= $self->info->has_data("artist")B= $self->info->has_data("title")
| |||||||||||||||||||||||||||||
| 21 | 0 | $self->status("Lyrics lookup requires ARTIST and TITLE already set!"); | |||||||||||||||||||||||||||
| 22 | 0 | return; | |||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | 1 | ▶ | if ( $self->info->lyrics && not $self->options->{lyricsoverwrite} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->info->lyrics and not $self->options->{"lyricsoverwrite"}
MC/DC0%0/2
$self->info->lyrics and not $self->options->{"lyricsoverwrite"}
$self->info->lyrics
not $self->options->{"lyricsoverwrite"}
Truth table33%1/3
A and not(B)
A= $self->info->lyricsB= not $self->options->{"lyricsoverwrite"}
| |||||||||||||||||||||||||||||
| 25 | 0 | $self->status("Lyrics already in tag"); | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | else { | ||||||||||||||||||||||||||||
| 28 | 1 | my $lyrics = Lyrics::Fetcher->fetch($self->info->get_data('artist'), $self->info->get_data('title'), $self->options->{lyricsfetchers}); | |||||||||||||||||||||||||||
| 29 | 1 | ▶ | if (($Lyrics::Fetcher::Error eq "OK") && ($lyrics)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$Lyrics::Fetcher::Error eq "OK" and $lyrics
MC/DC0%0/2
$Lyrics::Fetcher::Error eq "OK" and $lyrics
$Lyrics::Fetcher::Error eq "OK"
$lyrics
Truth table33%1/3
A and B
A= $Lyrics::Fetcher::Error eq "OK"B= $lyrics
| |||||||||||||||||||||||||||||
| 30 | 0 | my $lyricsl = $lyrics; | |||||||||||||||||||||||||||
| 31 | 0 | $lyricsl =~ s/[\r\n]+/ \/ /g; | |||||||||||||||||||||||||||
| 32 | 0 | $self->tagchange( "Lyrics", substr( "$lyricsl", 0, 50 ) . "..." ); | |||||||||||||||||||||||||||
| 33 | 0 | $self->info->set_data('lyrics',$lyrics); | |||||||||||||||||||||||||||
| 34 | 0 | $self->info->changed(1); | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | else { | ||||||||||||||||||||||||||||
| 37 | 1 | $self->status("Lyrics not found: ", $Lyrics::Fetcher::Error); | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | 1 | return $self; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 0 | ▶ | sub set_values { | ||||||||||||||||||||||||||
|
Subroutine
set_values: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 44 | 0 | return qw(lyrics); | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 2 | 1; | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | __END__ | ||||||||||||||||||||||||||||