Changeset 1236

Show
Ignore:
Timestamp:
11/07/09 18:27:16 (4 years ago)
Author:
mbarry
Message:

Attempt to guess at likely channel matches during configuration. Code from Greg Frost.

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/references/Shepherd/Configure.pm

    r1207 r1236  
    33package Shepherd::Configure; 
    44 
    5 my $version = '0.17'; 
     5my $version = '0.18'; 
    66 
    77use strict; 
     
    261261        $longname .= " ($mch->{callsign})" if ($mch->{callsign} and lc($mch->{callsign}) ne lc($longname)); 
    262262 
     263        my $default_str = ""; 
     264        my $default_index = 0; 
     265        my $guide_index = 0; 
     266 
     267        # Determine if the current xmltvid for the channel in the database 
     268        # corresponds to a shephed channel, and if it does, offer that as 
     269        # the default. 
     270 
     271        foreach (@table) 
     272        { 
     273            my $guide_xmltvid = $allchannels[$guide_index]; 
     274            $guide_xmltvid = lc "$guide_xmltvid.shepherd.au"; 
     275            $guide_xmltvid =~ s/ //g; 
     276 
     277            if ($guide_xmltvid eq $mch->{xmltvid}) 
     278            { 
     279                $default_index = $guide_index; 
     280            } 
     281 
     282            $guide_index++; 
     283        } 
     284 
     285        if ($default_index == 0) 
     286        { 
     287            my $munged_callsign = &munge($mch->{callsign}); 
     288            my $munged_name = &munge($mch->{name}); 
     289 
     290            ++$default_index until 
     291            munge($table[$default_index]) eq $munged_callsign or 
     292            munge($table[$default_index]) eq $munged_name or 
     293            $default_index > $#table; 
     294        } 
     295 
     296        if ($default_index > $#table) 
     297        { 
     298            $default_str = "0 (no guide)"; 
     299            $default_index = 0; 
     300        } 
     301        else 
     302        { 
     303            $default_str = "$table[$default_index]"; 
     304            $default_index++; 
     305            $default_str = "$default_index ($default_str)" 
     306        } 
     307 
    263308        my $channum = $mch->{channum} || '-'; 
    264         printf "MythTV channel %s: %s ? ", 
    265                $channum, 
    266                $longname; 
     309        printf "MythTV channel %s: %s [default=%s] ? ", 
     310               $channum, 
     311               $longname, 
     312               $default_str; 
    267313        my $inp = <STDIN>; 
    268314        chomp $inp; 
     
    282328            redo; 
    283329        } 
    284         elsif ($inp =~ /\d+/) 
     330 
     331        if ($inp eq "") 
     332        { 
     333            $inp = "$default_index"; 
     334        } 
     335 
     336        if ($inp =~ /\d+/) 
    285337        { 
    286338            my $xmltvid = ''; 
     
    11451197 
    11461198 
     1199# Convert callsigns and channel names for matching. 
     1200sub munge 
     1201{ 
     1202    my $ret = $_[0]; 
     1203 
     1204    # Convert to upercase. 
     1205 
     1206    $ret = uc($ret); 
     1207 
     1208    # Substitute numbers for words. 
     1209 
     1210    $ret =~s/12/TWELVE/g; 
     1211    $ret =~s/11/ELEVEN/g; 
     1212    $ret =~s/10/TEN/g; 
     1213    $ret =~s/9/NINE/g; 
     1214    $ret =~s/8/EIGHT/g; 
     1215    $ret =~s/7/SEVEN/g; 
     1216    $ret =~s/6/SIX/g; 
     1217    $ret =~s/5/FIVE/g; 
     1218    $ret =~s/4/FOUR/g; 
     1219    $ret =~s/3/THREE/g; 
     1220    $ret =~s/2/TWO/g; 
     1221    $ret =~s/1/ONE/g; 
     1222    $ret =~s/0/ZERO/g; 
     1223 
     1224    # Ignore "Digital" 
     1225 
     1226    $ret =~s/DIGITAL//g; 
     1227 
     1228    # Remove white space. 
     1229 
     1230    $ret =~s/[[:space:]]+//g; 
     1231 
     1232    # Make HDTV equivalent to HD 
     1233 
     1234    $ret =~s/HDTV/HD/g; 
     1235 
     1236    # Remove any non alphabetics. 
     1237 
     1238    $ret =~s/[^A-Z]//g; 
     1239 
     1240    return $ret; 
     1241} 
     1242 
     1243 
    11471244# ------------------------------ 
    11481245# -   Icons                    - 
  • trunk/status

    r1235 r1236  
    33reference       Shepherd/Common.pm  0.38 
    44reference       Shepherd/MythTV.pm  0.9 
    5 reference       Shepherd/Configure.pm   0.17 
     5reference       Shepherd/Configure.pm   0.18 
    66grabber         rex                 5.0.0 
    77grabber         news                1.6