Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl -w
- use LWP::Simple;
- use XML::Simple;
- use Data::Dumper;
- use JSON;
- use LWP::UserAgent;
- my $ua = LWP::UserAgent->new;
- my $parser = new XML::Simple;
- my $urlbase = "http://192.168.1.26:6544/Channel/";
- my $VideoSourceContent = get $urlbase
- . "GetVideoSourceList?&StartIndex=1";
- my $VideoSourceData = $parser->XMLin($VideoSourceContent);
- foreach my $VideoSource (@{$VideoSourceData->{VideoSources}->{VideoSource}})
- {
- my $sid = "$VideoSource->{Id}";
- my $ChannelContent = get $urlbase
- . "GetChannelInfoList?SourceID=$sid&StartIndex=1";
- my $ChannelData = $parser->XMLin($ChannelContent);
- foreach my $ChannelInfo (@{$ChannelData->{ChannelInfos}->{ChannelInfo}})
- {
- my $channame = $ChannelInfo->{ChannelName};
- my $callsign = $ChannelInfo->{CallSign};
- my $visible = $ChannelInfo->{Visible};
- if ( "$channame" =~ "GAME 4" ) {
- if ($ChannelInfo->{Visible} =~ "true") {
- $ChannelInfo->{Visible} = "false";
- } else {
- $ChannelInfo->{Visible} = "true";
- }
- my $json = encode_json $ChannelInfo;
- my $req = HTTP::Request->new(POST => $urlbase . "UpdateDBChannel");
- $req->header('content-type' => 'application/json');
- $req->content($json);
- my $resp = $ua->request($req);
- if ($resp->is_success) {
- my $message = $resp->decoded_content;
- print "$message\n";
- } else {
- print "error code: ", $resp->code, "\n";
- print "error mess: ", $resp->message, "\n";
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement