Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Re: Resort channels.conf



Hi Christian,

your script is very nice. But couldn't you modify it slightly, so the channels.order could simply be an existing channels.conf file? Then you could also modify the channels order with VDR and could still resort a new generated channels.conf (http://home1.pp.sbbs.se/beppes/getchannels.pl is really the ultimate channels.conf maker) with your script.

(unfortunately I don't know pearl, otherwise I would do it myself...)

Thanks

Dany

I've found it annoying to resort the channels.conf
after each update of vdr - and I didn't wanted to
miss updates from the channels.conf

So I wrote a small perl script to resort the channels.conf
according to an order given in a separate file.

Do

1> ./sort-channels.pl channels.conf channels.order channels.sorted
Wrote 4 sorted channels.
Wrote 175 other channels.

Maybe it's usefull for somebody.

--
Christian


--- sort-channels.pl ---

#!/usr/bin/perl

if ($#ARGV != 2) {
Usage();
exit;
}

$src = $ARGV[0];
$order = $ARGV[1];
$dest = $ARGV[2];

##########################################################################

open(ORDER, $order) || die "Cannot open $order: $!\n";
while ($line = <ORDER>) {
# may be too simple to remove the new line character
chop($line);
push(@sorted, $line);
}
close(ORDER);

open(SRC, $src) || die "Cannot open $src: $!\n";
while($line = <SRC>) {
$channel = ChannelName($line);
$channels{$channel} = $line;
push(@unsorted, $line);
}
close(SRC);

# write ordered channels in given order

open(DEST, ">$dest") || die "Cannot open $dest: $!\n";

print DEST ":My channels\n";

for ($i=0; $i <= $#sorted; $i++) {
$channel = $sorted[$i];
print DEST $channels{$channel};
delete $channels{$channel};
}

printf "Wrote %s sorted channels.\n", $#sorted;

# write all other channels in original order

print DEST ":All channels\n";

$count = 0;
for ($i=0; $i <= $#unsorted; $i++) {
$line = $unsorted[$i];
$channel = ChannelName($line);

# ignore channels already written
if($channels{$channel}) {
print DEST $line;
if(length($channel) != 0) {
$count++;
}
}
}
close(DEST);

printf "Wrote %s other channels.\n", $count;

##########################################################################

sub ChannelName {
local($name) = @_;

@split = split(":", $name);
$name = @split[0];
return $name;
}

sub Usage {
print "Usage: $0 <source file> <sort order file> <destination file>\n";
print "Sorts the VDR channels from the <source file> according to the\n";
print "sort order given in the <sort order file> and writes them to\n";
print "the <destination file>. All channels not mentioned in the sort\n";
print "order file are appended.\n";
}

--- channels.order ---

ARD
ZDF
RTL
Sat.1
Pro-7




-- No attachments (even text) are allowed --
-- Type: application/x-pkcs7-signature
-- File: smime.p7s
-- Desc: S/MIME Cryptographic Signature


--
Info:
To unsubscribe send a mail to listar@linuxtv.org with "unsubscribe vdr" as subject.



Home | Main Index | Thread Index