Advertisement
Guest User

Untitled

a guest
Nov 1st, 2014
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2.  
  3. use LWP::Simple;
  4. use XML::Simple;
  5. use Data::Dumper;
  6. use JSON;
  7. use LWP::UserAgent;
  8.  
  9. my $ua = LWP::UserAgent->new;
  10.  
  11. my $parser = new XML::Simple;
  12. my $urlbase = "http://192.168.1.26:6544/Channel/";
  13.  
  14. my $VideoSourceContent = get $urlbase
  15. . "GetVideoSourceList?&StartIndex=1";
  16.  
  17. my $VideoSourceData = $parser->XMLin($VideoSourceContent);
  18.  
  19. foreach my $VideoSource (@{$VideoSourceData->{VideoSources}->{VideoSource}})
  20. {
  21. my $sid = "$VideoSource->{Id}";
  22. my $ChannelContent = get $urlbase
  23. . "GetChannelInfoList?SourceID=$sid&StartIndex=1";
  24. my $ChannelData = $parser->XMLin($ChannelContent);
  25.  
  26. foreach my $ChannelInfo (@{$ChannelData->{ChannelInfos}->{ChannelInfo}})
  27. {
  28. my $channame = $ChannelInfo->{ChannelName};
  29. my $callsign = $ChannelInfo->{CallSign};
  30. my $visible = $ChannelInfo->{Visible};
  31. if ( "$channame" =~ "GAME 4" ) {
  32. if ($ChannelInfo->{Visible} =~ "true") {
  33. $ChannelInfo->{Visible} = "false";
  34. } else {
  35. $ChannelInfo->{Visible} = "true";
  36. }
  37. my $json = encode_json $ChannelInfo;
  38. my $req = HTTP::Request->new(POST => $urlbase . "UpdateDBChannel");
  39. $req->header('content-type' => 'application/json');
  40. $req->content($json);
  41. my $resp = $ua->request($req);
  42. if ($resp->is_success) {
  43. my $message = $resp->decoded_content;
  44. print "$message\n";
  45. } else {
  46. print "error code: ", $resp->code, "\n";
  47. print "error mess: ", $resp->message, "\n";
  48. }
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement