| 1 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # This file is part of Movies-Organizer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # This software is copyright (c) 2014 by celogeek <me@celogeek.com>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | package Movies::Organizer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # ABSTRACT: Organize your movies using imdb | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | our $VERSION = '1.3'; # VERSION | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use MooX::Options; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use File::Path 2.08 'make_path'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | ▶ | use File::Glob ':globally'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | ▶ | use File::Copy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | ▶ | use Term::ReadLine; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | ▶ | use Term::ReadLine::Perl; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | ▶ | use WWW::REST; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | ▶ | use JSON::XS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | option 'from' => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | doc => 'Source directory to organize', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | isa => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | my ($dest) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | croak "Source directory is missing !" unless -d $dest; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | required => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | format => 's', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | option 'to' => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | doc => 'Destination of the organized movies', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | isa => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | my ($dest) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | if ( !-d $dest ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | make_path( $dest, { error => \my $err } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | if (@$err) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | for my $diag (@$err) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | my ( $file, $message ) = %$diag; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | croak "Error : $message\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 1 | required => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | format => 's', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | option 'min_size' => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | default => sub { 100 * 1024**2 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 1 | doc => 'minimum size of file to handle it has movies', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | format => 'i', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | option 'with_aka' => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | default => sub {0}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 1 | doc => 'show alsa known as for movies title', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | has '_filter_words' => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | [ qw/ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | french | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | english | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | x264 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 720p | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 1080p | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | bluray | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | avi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | mkv | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | divx | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | bdrip | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | xvid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | brrip | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | ac3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | multi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | truefrench | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | dts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | hdma | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | hdtv | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | hdrip | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | m2ts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | s\d+ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | e\d+ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | s\d+e\d+ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | / | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | has '_rs' => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | my $rs = WWW::REST->new('http://imdbapi.org/'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | $rs->_ua->agent('Mozilla/5.0'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | $rs->dispatch( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | croak $self->status_line if $self->is_error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | my $ct = decode_json( $self->content ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | return ref $ct eq 'ARRAY' ? $ct->[0] : $ct; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | return $rs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | sub find_movies { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_movies: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | my @dir_to_scan = ( $self->from ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | my @movies; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | while ( my $dir = shift @dir_to_scan ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | $dir =~ s/ /\\ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | while ( my $cur = glob "$dir/*" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | push( @dir_to_scan, $cur ) and next if -d $cur; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
-d $cur && (push(@dir_to_scan, $cur) && (next))
push @dir_to_scan, $cur and next
MC/DC0%0/2
-d $cur && (push(@dir_to_scan, $cur) && (next))
-d $cur
push @dir_to_scan, $cur
Truth table0%0/3
A && B
A= -d $curB= push @dir_to_scan, $cur
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | push @movies, $cur if -s $cur >= $self->min_size; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | return @movies; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | sub filter_title { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
filter_title: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | my ( $self, $file ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | my ( undef, undef, $movie ) = File::Spec->splitpath($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | my @words_ok; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | SKIP_WORD: for my $word ( split( /\W+/x, $movie ) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | for my $filter ( @{ $self->_filter_words } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | next SKIP_WORD if $word =~ m/^$filter$/ix; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | push @words_ok, $word; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | return join( ' ', @words_ok ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | sub move_movie { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
move_movie: not called CC=15 SCAR=54.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | my ( $self, %options ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | my ( $term, $file, $imdb, $title, $season, $episode ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | = @options{qw/term file imdb title season episode/}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | my ( undef, undef, $movie ) = File::Spec->splitpath($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | my ( $season_part, $episode_part ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | my $is_series = $imdb->{type} eq 'TVS'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | if ($is_series) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | $season_part = sprintf( "S%02d", $season ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | $episode_part = sprintf( "E%02d", $episode ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | #extract ext | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | my ($ext) = $movie =~ m/\.([^\.]+)$/x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | $ext = "avi" unless defined $ext; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | #fix title space | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | $title =~ s/\W+/ /gx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | $title =~ s/^\s+|\s+$//gx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | $title =~ s/\s+(\w)/.\u$1/gx; #replace space by dot | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | #create destination | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | my $dest = File::Spec->catfile( $self->to, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | ucfirst( $imdb->{type} eq 'TVS' ? 'Tv series' : 'Movie' ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | if ($is_series) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $dest = File::Spec->catfile( $dest, $title, $season_part ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | make_path( $dest, { error => \my $err } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | if (@$err) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | for my $diag (@$err) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | my ( undef, $message ) = %$diag; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | croak "Error : $message\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | #build final filename | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | if ($is_series) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | $ext = join( '.', $season_part . $episode_part, $ext ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | $ext = join( '.', "(" . $imdb->{year} . ")", $ext ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | my $fdest = File::Spec->catfile( $dest, join( '.', $title, $ext ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | say "Moving : "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | say " From : ", $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | say " To : ", $fdest; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | exit unless $term->readline( 'Continue (Y/n) ? > ', 'y' ) eq 'y'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | move( $file, $fdest ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | croak "Error occur !" if -e $file || !-e $fdest; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-e $file or not -e $fdest
MC/DC0%0/2
-e $file or not -e $fdest
-e $file
not -e $fdest
Truth table0%0/3
A or not(B)
A= -e $fileB= not -e $fdest
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | $file =~ s/\.[^\.]+$/.srt/x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | $fdest =~ s/\.[^\.]+$/.srt/x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | if ( -e $file ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | say "Moving : "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | say " From : ", $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | say " To : ", $fdest; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | exit unless $term->readline( 'Continue (Y/n) ? > ', 'y' ) eq 'y'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | move( $file, $fdest ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | croak "Error occur !" if -e $file || !-e $fdest; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-e $file or not -e $fdest
MC/DC0%0/2
-e $file or not -e $fdest
-e $file
not -e $fdest
Truth table0%0/3
A or not(B)
A= -e $fileB= not -e $fdest
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | ## no critic qw(Subroutines::ProhibitExcessComplexity) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: not called CC=42 SCAR=75.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | my $term = Term::ReadLine->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | my ( $imdb, $movie_title, $season, $episode ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | for my $movie ( $self->find_movies() ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | say ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | say "Organize : $movie"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | my $another_episode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | if ( defined $imdb | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $imdb and $imdb->{"type"} eq "TVS" and $term->readline('is it another episode of ' . $movie_title . ' ? (Y/n) > ', "y") eq "y"
defined $imdb and $imdb->{"type"} eq "TVS"
MC/DC0%0/3
defined $imdb and $imdb->{"type"} eq "TVS" and $term->readline('is it another episode of ' . $movie_title . ' ? (Y/n) > ', "y") eq "y"
defined $imdb
$imdb->{"type"} eq "TVS"
$term->readline('is it another episode of ' . $movie_title . ' ? (Y/n) > ', "y") eq "y"
Truth table0%0/4
A and B and C
A= defined $imdbB= $imdb->{"type"} eq "TVS"C= $term->readline('is it another episode of ' . $movie_title . ' ? (Y/n) > ', "y") eq "y"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | && $imdb->{type} eq 'TVS' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | && $term->readline( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | "is it another episode of " . $movie_title . " ? (Y/n) > ", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | "y" ) eq "y" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | $another_episode = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | say ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | $imdb = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | if ( !$another_episode ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | while ( !defined $imdb ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | my $imdb_search = $term->readline( "IMDB Search > ", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | $self->filter_title($movie) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | my $imdb_search_key = $imdb_search =~ /^tt\d+/x ? 'id' : 'q'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | my $imdb_search_year | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | = $term->readline("Movie/Series Year > "); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | my @imdb_search_params = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | $imdb_search_key => $imdb_search, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | limit => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | plot => qw/full/, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | episode => 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | push @imdb_search_params, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | year => $imdb_search_year, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | yg => 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | if $imdb_search_year ne ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | $imdb = $self->_rs->get(@imdb_search_params); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | $imdb = undef if $imdb->{error}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | if ($imdb) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | ▶ | say "Movie : ", $imdb->{title} // ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$imdb->{"title"} // ""
MC/DC0%0/1
$imdb->{"title"} // ""
$imdb->{"title"}
Truth table0%0/2
A
A= $imdb->{"title"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | say "Aka : ", join( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | ', ', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | map { utf8::encode($_); $_ } ## no critic (ProhibitComplexMappings) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | @{ $imdb->{also_known_as} // [] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$imdb->{"also_known_as"} // []
MC/DC0%0/1
$imdb->{"also_known_as"} // []
$imdb->{"also_known_as"}
Truth table0%0/2
A
A= $imdb->{"also_known_as"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | ) if $self->with_aka; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | say "Kind : ", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | ( $imdb->{type} // "" ) eq 'TVS' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$imdb->{"type"} // ""
MC/DC0%0/1
$imdb->{"type"} // ""
$imdb->{"type"}
Truth table0%0/2
A
A= $imdb->{"type"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | ? 'Tv Serie' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | : 'Movie'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | say "Year : ", $imdb->{year} // ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$imdb->{"year"} // ""
MC/DC0%0/1
$imdb->{"year"} // ""
$imdb->{"year"}
Truth table0%0/2
A
A= $imdb->{"year"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | say "Plot : ", $imdb->{plot} // ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$imdb->{"plot"} // ""
MC/DC0%0/1
$imdb->{"plot"} // ""
$imdb->{"plot"}
Truth table0%0/2
A
A= $imdb->{"plot"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | say "Directory: ", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | join( ', ', @{ $imdb->{directors} // [] } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$imdb->{"directors"} // []
MC/DC0%0/1
$imdb->{"directors"} // []
$imdb->{"directors"}
Truth table0%0/2
A
A= $imdb->{"directors"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | say "Cast : ", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | join( ', ', @{ $imdb->{actors} // [] } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$imdb->{"actors"} // []
MC/DC0%0/1
$imdb->{"actors"} // []
$imdb->{"actors"}
Truth table0%0/2
A
A= $imdb->{"actors"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | say "Genre : ", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | join( ', ', @{ $imdb->{genres} // [] } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$imdb->{"genres"} // []
MC/DC0%0/1
$imdb->{"genres"} // []
$imdb->{"genres"}
Truth table0%0/2
A
A= $imdb->{"genres"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | say "Duration : ", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | join( ', ', @{ $imdb->{runtime} // [] } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$imdb->{"runtime"} // []
MC/DC0%0/1
$imdb->{"runtime"} // []
$imdb->{"runtime"}
Truth table0%0/2
A
A= $imdb->{"runtime"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | say "Language : ", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | join( ', ', @{ $imdb->{language} // [] } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$imdb->{"language"} // []
MC/DC0%0/1
$imdb->{"language"} // []
$imdb->{"language"}
Truth table0%0/2
A
A= $imdb->{"language"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | say ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | my $correct | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | = $term->readline( "Is it correct ? (Y/n) > ", "y" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | $imdb = undef unless $correct eq 'y'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | $movie_title = $imdb->{title}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | my @movie_titles = ($movie_title); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | push @movie_titles, @{ $imdb->{also_known_as} // [] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$imdb->{"also_known_as"} // []
MC/DC0%0/1
$imdb->{"also_known_as"} // []
$imdb->{"also_known_as"}
Truth table0%0/2
A
A= $imdb->{"also_known_as"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | if $self->with_aka; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | if ( @movie_titles > 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | my $choice; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | say "Select best title : "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | for ( my $i = 1; $i <= @movie_titles; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | say sprintf( " %d) %s", $i, $movie_titles[ $i - 1 ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | while ( !defined $choice ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | $choice = $term->readline( " > ", 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | $choice = undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$choice =~ /\D/x or $choice < 1 or $choice > @movie_titles
$choice =~ /\D/x or $choice < 1
MC/DC0%0/3
$choice =~ /\D/x or $choice < 1 or $choice > @movie_titles
$choice =~ /\D/x
$choice < 1
$choice > @movie_titles
Truth table0%0/4
A or B or C
A= $choice =~ /\D/xB= $choice < 1C= $choice > @movie_titles
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | if $choice =~ /\D/x | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | || $choice < 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | || $choice > @movie_titles; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | $movie_title = $movie_titles[ $choice - 1 ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | say ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | if ( $imdb->{type} eq 'TVS' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | my $ok = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | while ( !$ok || !defined $season || !defined $episode ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$ok and defined $season and defined $episode
$ok and defined $season
MC/DC0%0/3
$ok and defined $season and defined $episode
$ok
defined $season
defined $episode
Truth table0%0/4
A and B and C
A= $okB= defined $seasonC= defined $episode
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | $ok++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | $season = $term->readline( "Season ? > ", $season ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | $episode = $term->readline( "Episode ? > ", $episode ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | ▶ | if ( $season =~ /\D/x | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$season =~ /\D/x or $episode =~ /\D/x or $season eq "" or $episode eq ""
$season =~ /\D/x or $episode =~ /\D/x or $season eq ""
$season =~ /\D/x or $episode =~ /\D/x
MC/DC0%0/4
$season =~ /\D/x or $episode =~ /\D/x or $season eq "" or $episode eq ""
$season =~ /\D/x
$episode =~ /\D/x
$season eq ""
$episode eq ""
Truth table0%0/5
A or B or C or D
A= $season =~ /\D/xB= $episode =~ /\D/xC= $season eq ""D= $episode eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | || $episode =~ /\D/x | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | || $season eq '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | || $episode eq '' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | say "Please, use only numeric values !"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | say ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | $ok = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | if (!( $term->readline( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | "is it season " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | . $season | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | . " episode " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | . $episode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | . " ? (Y/n) > ", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | "y" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | ) eq "y" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | $ok = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | $self->move_movie( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | term => $term, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | file => $movie, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | imdb => $imdb, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | title => $movie_title, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | season => $season, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | episode => $episode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | ▶ | $episode++ if defined $episode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||