Advertisement
Guest User

HDHR_chans STRM Generator Script for Windows 7

a guest
Aug 22nd, 2012
445
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 2.58 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. # This script scans (an HDHR3-US) and creates a directory full of strm files ready to be used by XBMC
  4. # Copyright 2011 by jwater7 under the terms of the GNU General Public License
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  
  19.  
  20. use warnings;
  21. use strict;
  22.  
  23. $|=1; #disable output buffer
  24. my $tuner = '1';
  25. my $hdhr_config = 'hdhomerun_config.exe';
  26.  
  27. # Find hdhr_config
  28. #chomp(my $hdhr_config = `which hdhomerun_config`);
  29. #if (! -e $hdhr_config) {
  30. #   print "ERROR: hdhomerun_config must be in your path\n";
  31. #   exit 1;
  32. #}
  33.  
  34. # Make the output directory
  35. if(! -d "HDHR_chans") {
  36.    print "Making HDHR_chans directory...\n";
  37.    print "\t(look in here for the strm files)...\n";
  38.    mkdir ("HDHR_chans");
  39. }
  40.  
  41. chomp(my $device = `$hdhr_config discover`);
  42. $device =~ /device (.*) found/;
  43. $device = $1;
  44. print "Device found at: $device\n";
  45.  
  46. print "Scanning for channels using tuner$tuner...\n";
  47. if (open(SCANR, "$hdhr_config $device scan /tuner$tuner |")) {
  48.    my $chan = '';
  49.    while (my $line = <SCANR>) {
  50.       chomp($line);
  51.       print "Line = $line\n";          
  52.        
  53.       # Look for the start of a channel (like 51)
  54.       if ($line =~ m/SCANNING.*:([0-9]+)/) {
  55.          $chan = $1;
  56.       }
  57.       # Look for the program number (like 7.1)
  58.       # if ($line =~ m/PROGRAM\s([0-9]+.[0-9]+):\s([0-9]+.[0-9]+)\s(.*)/) {
  59.       if ($line =~ m/PROGRAM\s(.*):\s(.*)\s(.*)/) {
  60.          my $proxyProg = $1;
  61.          my $prog = $2;
  62.          my $cname = $3;
  63.          $cname =~ s/\s/_/;
  64.          print "*** Found Program $prog-$cname on channel $chan ***\n";
  65.          # print `echo "hdhomerun://$device-$tuner/tuner$tuner?channel=auto:$chan&program=$proxyProg" > "HDHR_chans/$prog.strm"`;
  66.          my $file = "HDHR_chans/$prog.strm";
  67.          open my $fh, '>', $file or die "Can't open $file - $!\n";
  68.          print $fh "hdhomerun://$device-$tuner/tuner$tuner?channel=auto:$chan&program=$proxyProg" ;
  69.       }
  70.    }
  71. }
  72.  
  73. print "Done.\n";
  74. exit 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement