From 83eca4d5923ba619d4098fadaa0d9a158902dae4 Mon Sep 17 00:00:00 2001 From: Tomica Crnek Date: Tue, 8 Mar 2011 14:05:02 +0100 Subject: [PATCH] Some changes... --- lib/NonameTV.pm | 16 ++++++++++++--- lib/NonameTV/Exporter/Conax.pm | 4 ++-- lib/NonameTV/Exporter/Dreampark.pm | 4 ++-- lib/NonameTV/Exporter/Lysis.pm | 4 ++-- lib/NonameTV/Importer/Cinestar.pm | 27 ++++++++++++------------ lib/NonameTV/Importer/Hayat.pm | 3 ++- lib/NonameTV/Importer/NetTV.pm | 30 ++++++++++++++++++++++++--- lib/NonameTV/Importer/OBN.pm | 22 ++++++++++++++------ lib/NonameTV/Importer/OSTV.pm | 10 ++++----- lib/NonameTV/Importer/TVDalmacija.pm | 20 ++++++++++++++++-- lib/NonameTV/Importer/Universal.pm | 40 ++++++++++++++++++++---------------- 11 files changed, 123 insertions(+), 57 deletions(-) diff --git a/lib/NonameTV.pm b/lib/NonameTV.pm index 148eb8d..9cc3648 100644 --- a/lib/NonameTV.pm +++ b/lib/NonameTV.pm @@ -715,7 +715,7 @@ Convert month name to month number sub MonthNumber { my( $monthname , $lang ) = @_; - my( @months_1, @months_2, @months_3, @months_4, @months_5, @months_6, @months_7 ); + my( @months_1, @months_2, @months_3, @months_4, @months_5, @months_6, @months_7, @months_8 ); if( $lang =~ /^en$/ ){ @months_1 = qw/jan feb mar apr may jun jul aug sep oct nov dec/; @@ -725,6 +725,7 @@ sub MonthNumber { @months_5 = qw/1 2 3 4 5 6 7 8 9 10 11 12/; @months_6 = qw/1 2 3 4 5 6 7 8 9 10 11 12/; @months_7 = qw/1 2 3 4 5 6 7 8 9 10 11 12/; + @months_8 = qw/1 2 3 4 5 6 7 8 9 10 11 12/; } elsif( $lang =~ /^de$/ ){ @months_1 = qw/jan feb mar apr may jun jul aug sep oct nov dec/; @months_2 = qw/Januar Februar März April Mai Juni Juli August September Oktober November Dezember/; @@ -733,6 +734,7 @@ sub MonthNumber { @months_5 = qw/1 2 3 4 5 6 7 8 9 10 11 12/; @months_6 = qw/1 2 3 4 5 6 7 8 9 10 11 12/; @months_7 = qw/1 2 3 4 5 6 7 8 9 10 11 12/; + @months_8 = qw/1 2 3 4 5 6 7 8 9 10 11 12/; } elsif( $lang =~ /^hr$/ ){ @months_1 = qw/sij vel ozu tra svi lip srp kol ruj lis stu pro/; @months_2 = qw/sijecanj veljaca ozujak travanj svibanj lipanj srpanj kolovoz rujan listopad studeni prosinac/; @@ -741,6 +743,7 @@ sub MonthNumber { @months_5 = qw/januar februar mart april maj juni juli august septembar oktobar novembar decembar/; @months_6 = qw/siječanj veljace ozujka travnja svibnja lipnja srpnja kolovoza rujna listopada studenog prosinca/; @months_7 = qw/jan feb mar apr maj jun jul aug sep okt nov dec/; + @months_8 = qw/siječnja feb mar apr maj jun jul aug sep okt nov dec/; } elsif( $lang =~ /^sr$/ ){ @months_1 = qw/jan feb mar apr maj jun jul aug sep okt nov dec/; @months_2 = qw/januar februar mart april maj jun juli avgust septembar oktobar novembar decembar/; @@ -749,6 +752,7 @@ sub MonthNumber { @months_5 = qw/1 2 3 4 5 6 7 8 9 10 11 12/; @months_6 = qw/1 2 3 4 5 6 7 8 9 10 11 12/; @months_7 = qw/1 2 3 4 5 6 7 8 9 10 11 12/; + @months_8 = qw/1 2 3 4 5 6 7 8 9 10 11 12/; } elsif( $lang =~ /^it$/ ){ @months_1 = qw/gen feb mar apr mag giu lug ago set ott nov dic/; @months_2 = qw/gennaio febbraio marzo aprile maggio giugno luglio agosto settembre ottobre novembre dicembre/; @@ -757,6 +761,7 @@ sub MonthNumber { @months_5 = qw/1 2 3 4 5 6 7 8 9 10 11 12/; @months_6 = qw/1 2 3 4 5 6 7 8 9 10 11 12/; @months_7 = qw/1 2 3 4 5 6 7 8 9 10 11 12/; + @months_8 = qw/1 2 3 4 5 6 7 8 9 10 11 12/; } elsif( $lang =~ /^fr$/ ){ @months_1 = qw/jan fav mar avr mai jui jul aou sep oct nov dec/; @months_2 = qw/JANVIER FÉVRIER mars avril mai juin juillet Août septembre octobre novembre DÉCEMBRE/; @@ -765,15 +770,16 @@ sub MonthNumber { @months_5 = qw/1 2 3 4 5 6 7 8 9 10 11 12/; @months_6 = qw/1 2 3 4 5 6 7 8 9 10 11 12/; @months_7 = qw/1 2 3 4 5 6 7 8 9 10 11 12/; + @months_8 = qw/1 2 3 4 5 6 7 8 9 10 11 12/; } elsif( $lang =~ /^ru$/ ){ - @months_1 = qw/jan fav mar aprelja maja jui jul aou - sep oct nov dec/; + @months_1 = qw/jan fav mar aprelja maja jui jul aou sep oct nov dec/; @months_2 = qw/JANVIER FÉVRIER mars avril mai juin juillet aout septembre octobre novembre DÉCEMBRE/; @months_3 = qw/janvier favrier mars avril mai juin juillet aout septembre octobre novembre DÉCEMBRE/; @months_4 = qw/1 2 3 4 5 6 7 8 9 10 11 12/; @months_5 = qw/1 2 3 4 5 6 7 8 9 10 11 12/; @months_6 = qw/1 2 3 4 5 6 7 8 9 10 11 12/; @months_7 = qw/1 2 3 4 5 6 7 8 9 10 11 12/; + @months_8 = qw/1 2 3 4 5 6 7 8 9 10 11 12/; } my %monthnames = (); @@ -806,6 +812,10 @@ sub MonthNumber { $monthnames{$months_7[$i]} = $i+1; } + for( my $i = 0; $i < scalar(@months_8); $i++ ){ + $monthnames{$months_8[$i]} = $i+1; + } + my $month = $monthnames{$monthname}; my $lcmonth = $monthnames{lc $monthname}; diff --git a/lib/NonameTV/Exporter/Conax.pm b/lib/NonameTV/Exporter/Conax.pm index 06b07a2..9d34102 100644 --- a/lib/NonameTV/Exporter/Conax.pm +++ b/lib/NonameTV/Exporter/Conax.pm @@ -453,7 +453,7 @@ sub create_dt ( $year, $month, $day ) = ( $str =~ /^(\d{4})-(\d{2})-(\d{2})$/ ); - logdie( "Conax: Unknown time format $str" ) + die( "Conax: Unknown time format $str" ) unless defined $day; return DateTime->new( @@ -867,7 +867,7 @@ sub ExportNetworks my $outfile = "$self->{Root}/$edata->{name}/network-information.xml"; open( my $fh, '>:encoding(' . $self->{Encoding} . ')', $outfile ) - or logdie( "Conax: cannot write to $outfile" ); + or die( "Conax: cannot write to $outfile" ); $odoc->toFH( $fh, 1 ); close( $fh ); diff --git a/lib/NonameTV/Exporter/Dreampark.pm b/lib/NonameTV/Exporter/Dreampark.pm index 32f54ec..edea96d 100644 --- a/lib/NonameTV/Exporter/Dreampark.pm +++ b/lib/NonameTV/Exporter/Dreampark.pm @@ -454,7 +454,7 @@ sub create_dt ( $year, $month, $day ) = ( $str =~ /^(\d{4})-(\d{2})-(\d{2})$/ ); - logdie( "Dreampark: Unknown time format $str" ) + die( "Dreampark: Unknown time format $str" ) unless defined $day; return DateTime->new( @@ -854,7 +854,7 @@ sub ExportMetaDataFile my $outfile = "$self->{Root}$edata->{name}/meta.xml"; open( my $fh, '>:encoding(' . $self->{Encoding} . ')', $outfile ) - or logdie( "Dreampark: cannot write to $outfile" ); + or die( "Dreampark: cannot write to $outfile" ); my $docstring = $odoc->toString( 1 ); my $fragstring = $root->toString( 1 ); diff --git a/lib/NonameTV/Exporter/Lysis.pm b/lib/NonameTV/Exporter/Lysis.pm index 043619c..bcaf48c 100644 --- a/lib/NonameTV/Exporter/Lysis.pm +++ b/lib/NonameTV/Exporter/Lysis.pm @@ -431,7 +431,7 @@ sub create_dt ( $year, $month, $day ) = ( $str =~ /^(\d{4})-(\d{2})-(\d{2})$/ ); - logdie( "Lysis: Unknown time format $str" ) + die( "Lysis: Unknown time format $str" ) unless defined $day; return DateTime->new( @@ -836,7 +836,7 @@ sub ExportNetworks my $outfile = "$self->{Root}/$edata->{name}/network-information.xml"; open( my $fh, '>:encoding(' . $self->{Encoding} . ')', $outfile ) - or logdie( "Lysis: cannot write to $outfile" ); + or die( "Lysis: cannot write to $outfile" ); $odoc->toFH( $fh, 1 ); close( $fh ); diff --git a/lib/NonameTV/Importer/Cinestar.pm b/lib/NonameTV/Importer/Cinestar.pm index 54581c9..74dc51e 100644 --- a/lib/NonameTV/Importer/Cinestar.pm +++ b/lib/NonameTV/Importer/Cinestar.pm @@ -54,7 +54,6 @@ sub ImportContentFile { my $date; my $currdate = "x"; - my $batch_id = $xmltvid . "_" . $file; $ds->StartBatch( $batch_id , $channel_id ); @@ -83,9 +82,9 @@ sub ImportContentFile { $columns{'Title CRO'} = $iC if( $oWkS->{Cells}[$iR][$iC]->Value =~ /^Title$/i ); $columns{'STARTTIME'} = $iC if( $oWkS->{Cells}[$iR][$iC]->Value =~ /^POČETAK$/i ); } -#foreach my $col (%columns) { -#print ">$col<\n"; -#} +foreach my $col (%columns) { +print ">$col<\n"; +} next; } @@ -95,7 +94,9 @@ sub ImportContentFile { next if( ! $oWkC ); next if( ! $oWkC->Value ); $date = ParseDate( $oWkC->Value ); +$date = $currdate if ( ! $date ); next if( ! $date ); +$currdate = $date; # starttime - column ('POČETAK') $oWkC = $oWkS->{Cells}[$iR][$columns{'STARTTIME'}]; @@ -122,12 +123,12 @@ sub ImportContentFile { next if( ! $crotitle ); my $progtype = $oWkS->{Cells}[$iR][$columns{'VRSTA'}]->Value if $oWkS->{Cells}[$iR][$columns{'VRSTA'}]; - my $origtitle = $oWkS->{Cells}[$iR][$columns{'ORG. NASLOV'}]->Value if $oWkS->{Cells}[$iR][$columns{'ORG. NASLOV'}]; + #my $origtitle = $oWkS->{Cells}[$iR][$columns{'ORG. NASLOV'}]->Value if $oWkS->{Cells}[$iR][$columns{'ORG. NASLOV'}]; my $year = $oWkS->{Cells}[$iR][$columns{'GODINA'}]->Value if $oWkS->{Cells}[$iR][$columns{'GODINA'}]; my $director = $oWkS->{Cells}[$iR][$columns{'REŽIJA'}]->Value if $oWkS->{Cells}[$iR][$columns{'REŽIJA'}]; - my $actor = $oWkS->{Cells}[$iR][$columns{'ULOGE'}]->Value if $oWkS->{Cells}[$iR][$columns{'ULOGE'}]; + #my $actor = $oWkS->{Cells}[$iR][$columns{'ULOGE'}]->Value if $oWkS->{Cells}[$iR][$columns{'ULOGE'}]; my $synopsis = $oWkS->{Cells}[$iR][$columns{'SINOPSIS'}]->Value if $oWkS->{Cells}[$iR][$columns{'SINOPSIS'}]; - my $genre = $oWkS->{Cells}[$iR][$columns{'ŽANR'}]->Value if $oWkS->{Cells}[$iR][$columns{'ŽANR'}]; + #my $genre = $oWkS->{Cells}[$iR][$columns{'ŽANR'}]->Value if $oWkS->{Cells}[$iR][$columns{'ŽANR'}]; #my $country = $oWkS->{Cells}[$iR][$columns{'ZEMLJA'}]->Value if $oWkS->{Cells}[$iR][$columns{'ZEMLJA'}]; #my $duration = $oWkS->{Cells}[$iR][$columns{'TRAJANJE'}]->Value if $oWkS->{Cells}[$iR][$columns{'TRAJANJE'}]; #my $rating = $oWkS->{Cells}[$iR][$columns{'DOBNA OZNAKA'}]->Value if $oWkS->{Cells}[$iR][$columns{'DOBNA OZNAKA'}]; @@ -142,19 +143,19 @@ sub ImportContentFile { }; # subtitle, etc... - $ce->{subtitle} = $origtitle if $origtitle; + #$ce->{subtitle} = $origtitle if $origtitle; $ce->{description} = $synopsis if $synopsis; $ce->{program_type} = $progtype if $progtype; $ce->{production_date} = "$year-01-01" if $year; $ce->{directors} = $director if $director; - $ce->{actors} = $actor if $actor; + #$ce->{actors} = $actor if $actor; # genre - if( $genre ){ - my($program_type, $category ) = $ds->LookupCat( "Cinestar", $genre ); - AddCategory( $ce, $program_type, $category ); - } +# if( $genre ){ +# my($program_type, $category ) = $ds->LookupCat( "Cinestar", $genre ); +# AddCategory( $ce, $program_type, $category ); +# } $ds->AddProgramme( $ce ); } diff --git a/lib/NonameTV/Importer/Hayat.pm b/lib/NonameTV/Importer/Hayat.pm index ddc7d98..72fad74 100644 --- a/lib/NonameTV/Importer/Hayat.pm +++ b/lib/NonameTV/Importer/Hayat.pm @@ -223,6 +223,7 @@ sub ImportFlatXLS next if( ! $oWkC->Value ); my $time = $oWkC->Value; $time =~ s/\s//; + next if( $time !~ /^\d+:\d+$/ ); # Title $oWkC = $oWkS->{Cells}[$iR][$coltitle]; @@ -297,7 +298,7 @@ sub isShow { sub ParseShow { my ( $text ) = @_; -#print ">$text<\n"; +print ">$text<\n"; my( $time, $title, $genre, $episode ); diff --git a/lib/NonameTV/Importer/NetTV.pm b/lib/NonameTV/Importer/NetTV.pm index bcef4c8..45136ed 100644 --- a/lib/NonameTV/Importer/NetTV.pm +++ b/lib/NonameTV/Importer/NetTV.pm @@ -59,6 +59,7 @@ sub ImportContentFile { my $date; + my %columns = (); my $kada; my $batch_id; my $currdate = "x"; @@ -76,8 +77,31 @@ sub ImportContentFile { for(my $iR = $oWkS->{MinRow} ; defined $oWkS->{MaxRow} && $iR <= $oWkS->{MaxRow} ; $iR++) { + # get the names of the columns from the 1st row + if( not %columns ){ + for(my $iC = $oWkS->{MinCol} ; defined $oWkS->{MaxCol} && $iC <= $oWkS->{MaxCol} ; $iC++) { + + next if( ! $oWkS->{Cells}[$iR][$iC] ); + next if( ! $oWkS->{Cells}[$iR][$iC]->Value ); + + $columns{norm($oWkS->{Cells}[$iR][$iC]->Value)} = $iC; + + # columns alternate names + $columns{'DATE'} = $iC if( $oWkS->{Cells}[$iR][$iC]->Value =~ /(ponedjeljak|utorak|srijeda|cetvrtak|petak|subota|nedjelja)/i ); + $columns{'TIME'} = $iC if( $oWkS->{Cells}[$iR][$iC]->Value =~ /^VRIJEME$/i ); + $columns{'TITLE'} = $iC if( $oWkS->{Cells}[$iR][$iC]->Value =~ /^IME EMISIJE$/i ); + } +#foreach my $col (%columns) { +#print ">$col<\n"; +#} + if( ! $columns{'DATE'} and ! $columns{'TIME'} and ! $columns{'TIME'} ){ + %columns = (); + } + next if %columns; + } + # Date - my $oWkC = $oWkS->{Cells}[$iR][0]; + my $oWkC = $oWkS->{Cells}[$iR][$columns{'DATE'}]; next if( ! $oWkC ); next if( ! $oWkC->Value ); @@ -103,7 +127,7 @@ sub ImportContentFile { } # time - $oWkC = $oWkS->{Cells}[$iR][0]; + $oWkC = $oWkS->{Cells}[$iR][$columns{'TIME'}]; next if( ! $oWkC ); next if( ! $oWkC->Value ); my $time = $oWkC->Value; @@ -111,7 +135,7 @@ sub ImportContentFile { $time =~ s/\./:/; # Title - $oWkC = $oWkS->{Cells}[$iR][1]; + $oWkC = $oWkS->{Cells}[$iR][$columns{'TITLE'}]; next if( ! $oWkC ); next if( ! $oWkC->Value ); my $title = $oWkC->Value; diff --git a/lib/NonameTV/Importer/OBN.pm b/lib/NonameTV/Importer/OBN.pm index 7a87262..59ddba2 100644 --- a/lib/NonameTV/Importer/OBN.pm +++ b/lib/NonameTV/Importer/OBN.pm @@ -165,6 +165,8 @@ sub isDate { return 1; } elsif( $text =~ /^(ponedjeljak|utorak|srijeda|ČETVRTAK|petak|subota|nedjelja),\s*\d+\.\s*(januar|veljače|mart|april|maj|juni|juli|august|septembar|oktobar|novembar|decembar)$/i ){ # format 'SUBOTA, 21. studeni' return 1; + } elsif( $text =~ /^(ponedjeljak|utorak|srijeda|ČETVRTAK|petak|subota|nedjelja),\s*\d+\.\d+\.\d+\.$/i ){ # SUBOTA, 26.02.2011. + return 1; } return 0; @@ -175,17 +177,20 @@ sub ParseDate { #print ">$text<\n"; - my( $dayname, $day, $monthname, $year ); + my( $dayname, $day, $monthname, $month, $year ); # format 'subota, 21.studeni 2009.' if( $text =~ /^(ponedjeljak|utorak|srijeda|ČETVRTAK|petak|subota|nedjelja),\s*\d+\.\s*(januar|veljače|mart|april|maj|juni|juli|august|septembar|oktobar|novembar|decembar)\s*\d+\.$/i ){ - ( $dayname, $day, $monthname, $year ) = ( $text =~ /^(\S+),\s*(\d+)\.\s*(\S+)\s*(\d+)\.$/i ) + ( $dayname, $day, $monthname, $year ) = ( $text =~ /^(\S+),\s*(\d+)\.\s*(\S+)\s*(\d+)\.$/i ); + $month = MonthNumber( $monthname , 'hr' ); } elsif( $text =~ /^(ponedjeljak|utorak|srijeda|ČETVRTAK|petak|subota|nedjelja),\s*\d+\.\s*(januar|veljače|mart|april|maj|juni|juli|august|septembar|oktobar|novembar|decembar)$/i ){ # format 'SUBOTA, 21. studeni' ( $dayname, $day, $monthname ) = ( $text =~ /^(\S+),\s*(\d+)\.\s*(\S+)$/i ); $year = DateTime->today->year(); + $month = MonthNumber( $monthname , 'hr' ); + } elsif( $text =~ /^(ponedjeljak|utorak|srijeda|ČETVRTAK|petak|subota|nedjelja),\s*\d+\.\d+\.\d+\.$/i ){ # SUBOTA, 26.02.2011. + ( $dayname, $day, $month, $year ) = ( $text =~ /^(\S+),\s*(\d+)\.(\d+)\.(\d+)\.$/i ); # SUBOTA, 26.02.2011. } - my $month = MonthNumber( $monthname , 'hr' ); return sprintf( '%d-%02d-%02d', $year, $month, $day ); } @@ -193,8 +198,10 @@ sub ParseDate { sub isShow { my ( $text ) = @_; +#print ">$text<\n"; + # format '09:00 Nasljednici zemlje, 4/8' - if( $text =~ /^\d+\:\d+\s+\S+/i ){ + if( $text =~ /^\d+[:|.]\d+\s+\S+/i ){ return 1; } @@ -204,9 +211,12 @@ sub isShow { sub ParseShow { my( $text ) = @_; - my( $time, $title, $genre, $epnum, $eptot, $rating ); +#print ">$text<\n"; + + my( $hour, $min, $time, $title, $genre, $epnum, $eptot, $rating ); - ( $time, $title ) = ( $text =~ /^(\d+\:\d+)\s+(.*)$/ ); + ( $hour, $min, $title ) = ( $text =~ /^(\d+)[:|.](\d+)\s+(.*)$/ ); + $time = $hour . ":" . $min; # parse episode # format '22:00 - Pepper Dennis, 5/13' diff --git a/lib/NonameTV/Importer/OSTV.pm b/lib/NonameTV/Importer/OSTV.pm index de4612e..71ebbd0 100644 --- a/lib/NonameTV/Importer/OSTV.pm +++ b/lib/NonameTV/Importer/OSTV.pm @@ -93,7 +93,7 @@ sub ImportContentFile if( isDate( $text ) ) { # the line with the date in format 'Friday 1st August 2008' $date = ParseDate( $text ); -print ">$date<\n"; +#print ">$date<\n"; if( $date ) { @@ -148,12 +148,12 @@ sub isDate { #print "isDate >$text<\n"; # format 'PETAK: 11. srpnja 2008.god.' - if( $text =~ /^(ponedjeljak|utorak|srijeda|ČETVRTAK|petak|subota|nedjelja):\s*\d+\.\s*(siječnja|veljače|ozujka|travnja|svibnja|lipnja|srpnja|kolovoza|rujna|listopada|studenog\a*|prosinca)\s*\d+\.\s*god\.$/i ){ + if( $text =~ /^(ponedjeljak|utorak|srijeda|ČETVRTAK|petak|subota|nedjelja):\s*\d+\.\s*(siječnja|veljače|ožujka|travnja|svibnja|lipnja|srpnja|kolovoza|rujna|listopada|studenog\a*|prosinca)\s*\d+\.\s*god\.$/i ){ return 1; } # format 'PONEDJELJAK\,* 5. srpnja 2010 - elsif( $text =~ /^(ponedjeljak|utorak|srijeda|ČETVRTAK|petak|subota|nedjelja)\,*\s*\d+\.\s*(siječnja|veljače|ozujka|travnja|svibnja|lipnja|srpnja|kolovoza|rujna|listopada|studenog\a*|prosinca)\s*\d+/i ){ + elsif( $text =~ /^(ponedjeljak|utorak|srijeda|ČETVRTAK|petak|subota|nedjelja)\,*\s*\d+\.\s*(siječnja|veljače|ožujka|travnja|svibnja|lipnja|srpnja|kolovoza|rujna|listopada|studenog\a*|prosinca)\s*\d+/i ){ return 1; } @@ -166,9 +166,9 @@ sub ParseDate { #print "ParseDate >$text<\n"; my( $dayname, $day, $monthname, $year ); - if( $text =~ /^(ponedjeljak|utorak|srijeda|ČETVRTAK|petak|subota|nedjelja):\s*\d+\.\s*(siječnja|veljače|ozujka|travnja|svibnja|lipnja|srpnja|kolovoza|rujna|listopada|studenog\a*|prosinca)\s*\d+\.\s*god\.$/i ){ + if( $text =~ /^(ponedjeljak|utorak|srijeda|ČETVRTAK|petak|subota|nedjelja):\s*\d+\.\s*(siječnja|veljače|ožujka|travnja|svibnja|lipnja|srpnja|kolovoza|rujna|listopada|studenog\a*|prosinca)\s*\d+\.\s*god\.$/i ){ ( $dayname, $day, $monthname, $year ) = ( $text =~ /^(\S+):\s*(\d+)\.\s*(\S+)\s*(\d+)\.\s*god\.$/ ); - } elsif( $text =~ /^(ponedjeljak|utorak|srijeda|ČETVRTAK|petak|subota|nedjelja)\,*\s*\d+\.\s*(siječnja|veljače|ozujka|travnja|svibnja|lipnja|srpnja|kolovoza|rujna|listopada|studenog\a*|prosinca)\s*\d+/i ){ + } elsif( $text =~ /^(ponedjeljak|utorak|srijeda|ČETVRTAK|petak|subota|nedjelja)\,*\s*\d+\.\s*(siječnja|veljače|ožujka|travnja|svibnja|lipnja|srpnja|kolovoza|rujna|listopada|studenog\a*|prosinca)\s*\d+/i ){ ( $dayname, $day, $monthname, $year ) = ( $text =~ /^(\S+)\,*\s*(\d+)\.\s*(\S+)\s*(\d+)/ ); } diff --git a/lib/NonameTV/Importer/TVDalmacija.pm b/lib/NonameTV/Importer/TVDalmacija.pm index 0fa61ca..90f1967 100644 --- a/lib/NonameTV/Importer/TVDalmacija.pm +++ b/lib/NonameTV/Importer/TVDalmacija.pm @@ -35,7 +35,6 @@ sub new { my $self = $class->SUPER::new( @_ ); bless ($self, $class); - my $dsh = NonameTV::DataStore::Helper->new( $self->{datastore} ); $self->{datastorehelper} = $dsh; @@ -196,9 +195,15 @@ sub FlushDayData { sub isDate { my ( $text ) = @_; +#print "isDate >$text<\n"; + # format 'Petak 18.07.2008.' if( $text =~ /^(ponedjeljak|utorak|srijeda|Četvrtak|petak|subota|nedjelja)\s*\d+\.\d+\.\d+\.\s*$/i ){ return 1; + + # format 'Petak 25.02.' + } elsif( $text =~ /^(ponedjeljak|utorak|srijeda|Četvrtak|petak|subota|nedjelja)\s*\d+\.\d+\.\s*$/i ){ + return 1; } return 0; @@ -207,7 +212,18 @@ sub isDate { sub ParseDate { my( $text ) = @_; - my( $dayname, $day, $month, $year ) = ( $text =~ /^(\S+)\s*(\d+)\.(\d+)\.(\d+)\.\s*$/ ); + my( $dayname, $day, $month, $year ); + + # format 'Petak 18.07.2008.' + if( $text =~ /^(ponedjeljak|utorak|srijeda|Četvrtak|petak|subota|nedjelja)\s*\d+\.\d+\.\d+\.\s*$/i ){ + ( $dayname, $day, $month, $year ) = ( $text =~ /^(\S+)\s*(\d+)\.(\d+)\.(\d+)\.\s*$/ ); + + # format 'Petak 25.02.' + } elsif( $text =~ /^(ponedjeljak|utorak|srijeda|Četvrtak|petak|subota|nedjelja)\s*\d+\.\d+\.\s*$/i ){ + ( $dayname, $day, $month ) = ( $text =~ /^(\S+)\s*(\d+)\.(\d+)\.\s*$/ ); + $year = DateTime->today->year(); + } + return sprintf( '%d-%02d-%02d', $year, $month, $day ); } diff --git a/lib/NonameTV/Importer/Universal.pm b/lib/NonameTV/Importer/Universal.pm index e66e079..114d609 100644 --- a/lib/NonameTV/Importer/Universal.pm +++ b/lib/NonameTV/Importer/Universal.pm @@ -70,6 +70,10 @@ sub ImportContentFile { # get the names of the columns from the 1st row if( not %columns ){ for(my $iC = $oWkS->{MinCol} ; defined $oWkS->{MaxCol} && $iC <= $oWkS->{MaxCol} ; $iC++) { + + next if( ! $oWkS->{Cells}[$iR][$iC] ); + next if( ! $oWkS->{Cells}[$iR][$iC]->Value ); + $columns{norm($oWkS->{Cells}[$iR][$iC]->Value)} = $iC; # columns alternate names @@ -109,18 +113,18 @@ sub ImportContentFile { my $titlecro = $oWkS->{Cells}[$iR][$columns{'Title CRO'}]->Value if $oWkS->{Cells}[$iR][$columns{'Title CRO'}]; my $type = $oWkS->{Cells}[$iR][$columns{'Type'}]->Value if $oWkS->{Cells}[$iR][$columns{'Type'}]; - my $prodno = $oWkS->{Cells}[$iR][$columns{'Prod No.'}]->Value if $oWkS->{Cells}[$iR][$columns{'Prod No.'}]; - my $episodetitle = $oWkS->{Cells}[$iR][$columns{'Episode Title'}]->Value if $oWkS->{Cells}[$iR][$columns{'Episode Title'}]; - my $slotlen = $oWkS->{Cells}[$iR][$columns{'Slot Len'}]->Value if $oWkS->{Cells}[$iR][$columns{'Slot Len'}]; - my $epino = $oWkS->{Cells}[$iR][$columns{'Epi No.'}]->Value if $oWkS->{Cells}[$iR][$columns{'Epi No.'}]; - my $cert = $oWkS->{Cells}[$iR][$columns{'Cert'}]->Value if $oWkS->{Cells}[$iR][$columns{'Cert'}]; + #my $prodno = $oWkS->{Cells}[$iR][$columns{'Prod No.'}]->Value if $oWkS->{Cells}[$iR][$columns{'Prod No.'}]; + #my $episodetitle = $oWkS->{Cells}[$iR][$columns{'Episode Title'}]->Value if $oWkS->{Cells}[$iR][$columns{'Episode Title'}]; + #my $slotlen = $oWkS->{Cells}[$iR][$columns{'Slot Len'}]->Value if $oWkS->{Cells}[$iR][$columns{'Slot Len'}]; + #my $epino = $oWkS->{Cells}[$iR][$columns{'Epi No.'}]->Value if $oWkS->{Cells}[$iR][$columns{'Epi No.'}]; + #my $cert = $oWkS->{Cells}[$iR][$columns{'Cert'}]->Value if $oWkS->{Cells}[$iR][$columns{'Cert'}]; my $genre = $oWkS->{Cells}[$iR][$columns{'Genre'}]->Value if $oWkS->{Cells}[$iR][$columns{'Genre'}]; my $year = $oWkS->{Cells}[$iR][$columns{'Year'}]->Value if $oWkS->{Cells}[$iR][$columns{'Year'}]; my $director = $oWkS->{Cells}[$iR][$columns{'Director'}]->Value if $oWkS->{Cells}[$iR][$columns{'Director'}]; my $actor = $oWkS->{Cells}[$iR][$columns{'Actor'}]->Value if $oWkS->{Cells}[$iR][$columns{'Actor'}]; - my $episodesynopsis = $oWkS->{Cells}[$iR][$columns{'Episode Synopsis'}]->Value if $oWkS->{Cells}[$iR][$columns{'Episode Synopsis'}]; - my $minisynopsis = $oWkS->{Cells}[$iR][$columns{'Mini Synopsis'}]->Value if $oWkS->{Cells}[$iR][$columns{'Mini Synopsis'}]; - my $synopsis = $oWkS->{Cells}[$iR][$columns{'Synopsis'}]->Value if $oWkS->{Cells}[$iR][$columns{'Synopsis'}]; + #my $episodesynopsis = $oWkS->{Cells}[$iR][$columns{'Episode Synopsis'}]->Value if $oWkS->{Cells}[$iR][$columns{'Episode Synopsis'}]; + #my $minisynopsis = $oWkS->{Cells}[$iR][$columns{'Mini Synopsis'}]->Value if $oWkS->{Cells}[$iR][$columns{'Mini Synopsis'}]; + #my $synopsis = $oWkS->{Cells}[$iR][$columns{'Synopsis'}]->Value if $oWkS->{Cells}[$iR][$columns{'Synopsis'}]; progress("Universal: $xmltvid: $starttime - $title"); @@ -132,23 +136,23 @@ sub ImportContentFile { }; # subtitle - if( $episodetitle ){ - $ce->{subtitle} = $episodetitle; - } elsif( $titlecro ){ - $ce->{subtitle} = $title; - } +# if( $episodetitle ){ +# $ce->{subtitle} = $episodetitle; +# } elsif( $titlecro ){ +# $ce->{subtitle} = $title; +# } - $ce->{description} = $synopsis if $synopsis; + #$ce->{description} = $synopsis if $synopsis; $ce->{program_type} = $type if $type; $ce->{production_date} = "$year-01-01" if $year; $ce->{directors} = $director if $director; $ce->{actors} = $actor if $actor; # episode - if( $epino ){ - $ce->{episode} = sprintf( ". %d .", $epino-1 ); - $ce->{program_type} = 'series'; - } +# if( $epino ){ +# $ce->{episode} = sprintf( ". %d .", $epino-1 ); +# $ce->{program_type} = 'series'; +# } # genre if( $genre ){ -- 2.11.4.GIT