~ubuntu-branches/ubuntu/raring/xmltv/raring

« back to all changes in this revision

Viewing changes to grab/es_laguiatv/tv_grab_es_laguiatv

  • Committer: Bazaar Package Importer
  • Author(s): Chris Butler
  • Date: 2010-11-29 19:43:10 UTC
  • mfrom: (1.4.1 upstream) (20.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20101129194310-o2lptjn26an5lq77
Tags: 0.5.59-1
* New upstream release
  - added new grabbers: pt_meo and fi_sv
* Refreshed patches
* Fixed tv_grab_fi by updating to revision 1.58 from upstream CVS 
  (closes: #605467)

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
error.
55
55
 
56
56
B<--capabilities> Show which capabilities the grabber supports. For more
57
 
information, see L<http://membled.com/twiki/bin/view/Main/XmltvCapabilities>
 
57
information, see L<http://wiki.xmltv.org/index.php/XmltvCapabilities>
58
58
 
59
59
B<--version> Show the version of the grabber.
60
60
 
79
79
# initializations
80
80
 
81
81
use strict;
82
 
use XMLTV::Version '$Id: tv_grab_es_laguiatv,v 1.12 2010/03/12 07:53:45 candu_sf Exp $ ';
 
82
use XMLTV::Version '$Id: tv_grab_es_laguiatv,v 1.16 2010/11/21 14:49:59 dekarl Exp $ ';
83
83
use XMLTV::Capabilities qw/baseline manualconfig cache/;
84
84
use XMLTV::Description 'Spain (laguiatv.com)';
85
85
use Getopt::Long;
113
113
my $HEAD = { 'source-info-url'     => 'http://www.laguiatv.com/programacion.php',
114
114
             'source-data-url'     => "http://www.laguiatv.com/programacion_vertical.php",
115
115
             'generator-info-name' => 'XMLTV',
116
 
             'generator-info-url'  => 'http://membled.com/work/apps/xmltv/',
 
116
             'generator-info-url'  => 'http://xmltv.org/',
117
117
           };
118
118
                   
119
119
# Whether zero-length programmes should be included in the output.
133
133
#       print $str;
134
134
}
135
135
 
 
136
# hard-coded list of TDT channels since laguia dont list them separately
 
137
my @tdt_channels = (
 
138
    "La 10",
 
139
    "Antena.neox",
 
140
    "Antena.nova",
 
141
    "Clan / TVE 50",
 
142
    "Factor{icute}a de Ficci{ocute}n Telecinco",
 
143
    "Boing",
 
144
    "Gol TV",
 
145
    "La Siete",
 
146
    "Veo7",
 
147
    "LaSexta2",
 
148
    "LaSexta3",
 
149
    "Nitro",
 
150
    "Canal 24 horas",
 
151
    "CNN+"
 
152
);
 
153
 
 
154
# hard-coded list of channels to hide from channel list
 
155
my @hide_channels = (
 
156
    "Clan  TVE 50", # missing / in name
 
157
);
 
158
 
136
159
 
137
160
######################################################################
138
161
# get options
630
653
}
631
654
 
632
655
 
633
 
sub get_prog_info()
 
656
sub get_prog_info
634
657
{
635
658
        my ($url) = @_;
636
659
        my $desc = "";
646
669
        foreach my $div(@divs)
647
670
        {
648
671
                my $class = $div->attr('class');
649
 
                if ($class && $class eq "losdatos")
 
672
                if ($class && $class eq "intro-datasheet")
650
673
                {
651
674
                        # debug_print "got losdatos\n"; 
652
675
                        my @subdivs = $div->find_by_tag_name("_tag"=>"div");
653
 
                
 
676
                                        
654
677
                        foreach my $subdiv(@subdivs)
655
678
                        {
656
679
                                # debug_print "subdiv\n";       
657
680
                                $class = $subdiv->attr('class');
658
 
                                if ($class && $class eq "entradilla")
 
681
                                if ($class && $class eq "text")
659
682
                                {
660
 
                                        debug_print "got entradilla\n"; 
661
 
 
662
 
                                        my $big_text = $div->as_text;
663
 
                                        # debug_print "BigText: $big_text\n";
664
 
                
665
 
                                        my $begin = index($big_text, "En este");
666
 
                                        if($begin >= 0)
667
 
                                        {
668
 
                                                my $ep_text = substr($big_text, $begin + 7); 
669
 
                                                # Find the next colon
670
 
                                                $begin = index($ep_text, ":");
671
 
                                                if($begin >= 0)
672
 
                                                {
673
 
                                                        $desc = substr($ep_text, $begin + 1); 
674
 
                                                }
675
 
                                                else
676
 
                                                {
677
 
                                                        $desc = $ep_text;
678
 
                                                }
679
 
                                        }
680
 
                                        else
681
 
                                        {
682
 
                                                $desc = $big_text;
683
 
                                        }
 
683
                                        my @ps = $div->find_by_tag_name("_tag"=>"p");
684
684
                                        
685
 
                                        my $end = index($desc, "FICHA T");
686
 
                                        if($end >= 0)
 
685
                                        foreach my $p(@ps)
687
686
                                        {
688
 
                                                $desc = substr($desc, 0, $end);
 
687
                                                $class = $p->attr('class');
 
688
                                
 
689
                                                if ($class && $class eq "desc")
 
690
                                                {
 
691
                                                        debug_print "got desc\n";       
 
692
 
 
693
                                                        $desc = $desc . $p->as_text;
 
694
                                                }
689
695
                                        }
690
 
                
691
 
                                        debug_print "Desc: $desc\n";
692
696
                                }
693
697
                        }
694
698
                }
695
699
        }
696
700
 
 
701
        debug_print "desc: $desc\n";    
 
702
 
697
703
        return ($desc,$cat);
698
704
}
699
705
 
725
731
    my $url="http://www.laguiatv.com/programacion.php";
726
732
    t $url;
727
733
 
 
734
        my $channel_id;
 
735
        my $channel_name;
 
736
        my $elem;
 
737
 
728
738
    my $tree = get_nice_tree $url;
729
739
 
 
740
    # Add hard-coded TDT channels (bad chris)
 
741
    foreach $channel_name (@tdt_channels)
 
742
    {
 
743
        $channel_id = convert_name_to_id($channel_name);
 
744
        debug_print "Channel $channel_name, id $channel_id\n";
 
745
        $channels{$channel_id}=$channel_name;
 
746
    }
730
747
 
731
748
# <input type="checkbox" name="nacionales1" value="TVE 1"
732
749
        # find the channels that are in check boxes
733
750
    my @options = $tree->find_by_tag_name("_tag"=>"input");
734
751
 
735
 
        my $channel_id;
736
 
        my $channel_name;
737
 
        my $elem;
738
 
 
739
752
    foreach $elem (@options) 
740
753
        {
741
754
                my $ename = $elem->attr('name');
778
791
                }
779
792
        }
780
793
 
 
794
    # remove channels that should not be listed
 
795
    foreach $channel_name (@hide_channels)
 
796
    {
 
797
        $channel_id = convert_name_to_id($channel_name);
 
798
        delete $channels{$channel_id};
 
799
    }
 
800
 
781
801
    die "no channels could be found" if not keys %channels;
782
802
    update $bar if not $opt_quiet;
783
803
    $bar->finish() if not $opt_quiet;
789
809
    my ($str) = @_;
790
810
 
791
811
 
792
 
        $str =~ s/([^A-Za-z0-9])/sprintf("-%02X", ord($1))/seg;
 
812
        $str =~ s/([^A-Za-z0-9])/sprintf("-%02X", ord("$1"))/seg;
793
813
 
794
814
        $str = "C" . $str;
795
815
        return $str;