Changeset 437

Show
Ignore:
Timestamp:
01/09/07 19:32:15 (6 years ago)
Author:
max
Message:

Reworked channel list

This only affects a small number of rural regions. It provides
a standardised way of distinguishing between similarly named
stations in those areas; e.g. "Prime (Regional)" and "Prime
(Albury)".

Files:
2 modified

Legend:

Unmodified
Added
Removed
  • applications/shepherd

    r424 r437  
    22 
    33my $progname = 'shepherd'; 
    4 my $version = '0.4.31'; 
     4my $version = '0.4.32'; 
    55 
    66# tv_grab_au 
     
    10071007    else 
    10081008    { 
    1009         $ua->agent('Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322') 
     1009        $ua->agent('Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322'); 
    10101010    } 
    10111011 
     
    13161316{ 
    13171317    my $REGIONS = { 
    1318         "ACT" => 126, 
    1319         "NSW: Sydney" => 73, 
    1320         "NSW: Newcastle" => 184, 
    1321         "NSW: Central Coast" => 66, 
    1322         "NSW: Griffith" => 67, 
    1323         "NSW: Broken Hill" => 63, 
    1324         "NSW: Northern NSW" => 69, 
    1325         "NSW: Southern NSW" => 71, 
    1326         "NSW: Remote and Central" => 106, 
    1327         "NT: Darwin" => 74, 
    1328         "NT: Remote & Central" => 108, 
    1329         "QLD: Brisbane" => 75, 
    1330         "QLD: Gold Coast" => 78, 
    1331         "QLD: Regional" => 79, 
    1332         "QLD: Remote & Central" => 114, 
    1333         "SA: Adelaide" => 81, 
    1334         "SA: Renmark" => 82, 
    1335         "SA: Riverland" => 83, 
    1336         "SA: South East SA" => 85, 
    1337         "SA: Spencer Gulf" => 86, 
    1338         "SA: Remote & Central" => 107, 
    1339         "Tasmania" => 88, 
    1340         "VIC: Melbourne" => 94, 
    1341         "VIC: Geelong" => 93, 
    1342         "VIC: Eastern Victoria" => 90, 
    1343         "VIC: Mildura/Sunraysia" => 95, 
    1344         "VIC: Western Victoria" => 98, 
    1345         "WA: Perth" => 101, 
    1346         "WA: Regional" => 102 
     1318        126 => "ACT", 
     1319        73 => "NSW: Sydney", 
     1320        184 => "NSW: Newcastle", 
     1321        66 => "NSW: Central Coast", 
     1322        67 => "NSW: Griffith", 
     1323        63 => "NSW: Broken Hill", 
     1324        69 => "NSW: Northern NSW", 
     1325        71 => "NSW: Southern NSW", 
     1326        106 => "NSW: Remote and Central", 
     1327        74 => "NT: Darwin", 
     1328        108 => "NT: Remote & Central", 
     1329        75 => "QLD: Brisbane", 
     1330        78 => "QLD: Gold Coast", 
     1331        79 => "QLD: Regional", 
     1332        114 => "QLD: Remote & Central", 
     1333        81 => "SA: Adelaide", 
     1334        82 => "SA: Renmark", 
     1335        83 => "SA: Riverland", 
     1336        85 => "SA: South East SA", 
     1337        86 => "SA: Spencer Gulf", 
     1338        107 => "SA: Remote & Central", 
     1339        88 => "Tasmania", 
     1340        94 => "VIC: Melbourne", 
     1341        93 => "VIC: Geelong", 
     1342        90 => "VIC: Eastern Victoria", 
     1343        95 => "VIC: Mildura/Sunraysia", 
     1344        98 => "VIC: Western Victoria", 
     1345        101 => "WA: Perth", 
     1346        102 => "WA: Regional" 
    13471347    }; 
    13481348 
    13491349    print "\nConfiguring.\n\n" . 
    13501350          "Select your region:\n"; 
    1351     foreach (sort keys %$REGIONS) 
    1352     { 
    1353         printf(" (%3d) %s\n", $REGIONS->{$_}, $_); 
    1354     } 
    1355     $region = ask_choice("Enter region code:", "94", values %$REGIONS); 
     1351    foreach (sort { $REGIONS->{$a} cmp $REGIONS->{$b} } keys %$REGIONS) 
     1352    { 
     1353        printf(" (%3d) %s\n", $_, $REGIONS->{$_}); 
     1354    } 
     1355    $region = ask_choice("Enter region code:", "94", keys %$REGIONS); 
    13561356 
    13571357    print "\nFetching channel information... "; 
    13581358 
    1359     my @channellist = get_channels(); 
     1359    my @channellist = &get_channels($REGIONS->{$region}); 
    13601360 
    13611361    print "done.\n\n" . 
     
    13631363          "of your choice (e.g. \"seven.free.au\"). If you don't need\n" . 
    13641364          "guide data for this channel, just press Enter.\n\n" . 
     1365          "Your region has the following channels:\n " .  
     1366          join(', ', @channellist) . ".\n\n" . 
    13651367          "Please don't subscribe to unneeded channels.\n\nChannels:\n"; 
    13661368    $channels = {}; 
     
    14581460} 
    14591461 
    1460 sub get_channels 
     1462# Obsolete but left for now in case we want to go back to it 
     1463sub get_channels_yahoo 
    14611464{ 
    14621465    my @date = localtime; 
     
    14681471    { 
    14691472        push @channellist, $1; 
     1473    } 
     1474    return @channellist; 
     1475} 
     1476 
     1477# Sourced from YourTV 
     1478sub get_channels 
     1479{ 
     1480    my $regionname = shift; 
     1481 
     1482    # Download list 
     1483    my $ua = LWP::UserAgent->new(); 
     1484    $ua->agent('Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322'); 
     1485    $ua->cookie_jar({}); 
     1486    $ua->get('http://www.yourtv.com.au'); 
     1487    my $response = $ua->get('http://www.yourtv.com.au/profile/ajax.cfm?action=channels&region_id='.$region); 
     1488 
     1489    my $page = $response->content; 
     1490    die "Unable to download channel list" if ($response->is_error()); 
     1491 
     1492    # Rules for Station Names: 
     1493    # Station names are comprised of the channel name (eg "Seven") and an 
     1494    # optional regional qualifier in brackets (eg "(Cairns/Rockhampton)"). 
     1495    # Station names shall not contain a regional qualifer unless 
     1496    # necessary to distinguish between identical channel names in 
     1497    # the same region; in this case, a regional qualifier shall always 
     1498    # be included. In the absence of anything better, the region name  
     1499    # (eg "NSW: Regional NSW") is used as the regional qualifier. 
     1500    my (@channellist, $clist, $cn, $rq); 
     1501    while ($page =~ /<label for="venue_id.*?>(.*?)<\/label>/sg) 
     1502    { 
     1503        my $channel = $1; 
     1504        $channel =~ s/\s{2,}//g; 
     1505        if ($channel =~ /(.*) (\(.*\))/) 
     1506        { 
     1507            ($cn, $rq) = ($1, $2); 
     1508        } 
     1509        else 
     1510        { 
     1511            $cn = $channel; 
     1512            $rq = ''; 
     1513        } 
     1514        # Is there already a channel with this name? 
     1515        if ($clist->{$cn}) 
     1516        { 
     1517            # Set regional qualifier for existing station if not already set 
     1518            if (@{$clist->{$cn}} == 1 and $clist->{$cn}[0] eq '') 
     1519            { 
     1520                $clist->{$cn} = [ "($regionname)" ]; 
     1521            } 
     1522            $rq = $regionname if ($rq eq ''); 
     1523            die "Bad channel list in region $region!" if (grep($rq eq $_, @{$clist->{$cn}})); 
     1524            push @{$clist->{$cn}}, $rq;  
     1525        } 
     1526        else 
     1527        { 
     1528            $clist->{$cn} = [ $rq ]; 
     1529        } 
     1530    } 
     1531    foreach $cn (keys %$clist) 
     1532    { 
     1533        if (@{$clist->{$cn}} == 1) 
     1534        { 
     1535            push @channellist, $cn; 
     1536        } 
     1537        else 
     1538        { 
     1539            foreach $rq (@{$clist->{$cn}}) 
     1540            { 
     1541                push @channellist, "$cn $rq"; 
     1542            } 
     1543        } 
    14701544    } 
    14711545    return @channellist; 
  • status

    r436 r437  
    1 application     shepherd            0.4.31 
     1application     shepherd            0.4.32 
    22grabber         yahoo7widget        1.72 
    33grabber         rex                 3.3.9