Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Update plexWatch.pl #137

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions plexWatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -753,16 +753,16 @@ ()
}
}

$format =~ s/{{($regex)}}/$info->{$1}/g; ## regex replace variables
$format =~ s/\{\{($regex)\}\}/$info->{$1}/g; ## regex replace variables
$format =~ s/\[\]//g; ## trim any empty variable encapsulated in []
$format =~ s/\s+/ /g; ## remove double spaces
$format =~ s/\\n/\n/g; ## allow \n to be an actual new line
$format =~ s/{{newline}}/\n/g; ## allow \n to be an actual new line
$format =~ s/\{\{newline\}\}/\n/g; ## allow \n to be an actual new line

## special for now.. might make this more useful -- just thrown together since email can include a ton of info

if ($format =~ /{{all_details}}/i) {
$format =~ s/\s*{{all_details}}\s*//i;
if ($format =~ /\{\{all_details\}\}/i) {
$format =~ s/\s*\{\{all_details\}\}\s*//i;
$format .= sprintf("\n\n%10s %s\n","","-----All Details-----");
my $f_extra;
foreach my $key (keys %{$info} ) {
Expand Down Expand Up @@ -3790,7 +3790,7 @@ ()
$ua->default_header('X-Plex-Client-Identifier' => $appname);
$ua->default_header('Content-Length' => 0);

my $url = 'https://my.plexapp.com/users/sign_in.xml';
my $url = 'https://plex.tv/users/sign_in.json';

my $req = HTTP::Request->new(POST => $url);
$req->authorization_basic($myPlex_user, $myPlex_pass);
Expand All @@ -3800,15 +3800,20 @@ ()

if ($response->is_success) {
my $content = $response->decoded_content();

if ($debug_xml) {
print "URL: $url\n";
print "===================================XML CUT=================================================\n";
print $content;
print "===================================XML END=================================================\n";
}
my $data = XMLin(encode('utf8',$content));
return $data->{'authenticationToken'} if $data->{'authenticationToken'};
return $data->{'authentication-token'} if $data->{'authentication-token'};

my $json = JSON->new->allow_nonref
->utf8->relaxed;
my $data = $json->decode( $content );

return $data->{user}->{authToken} if $data->{user}->{authToken};
return $data->{user}->{'authentication-token'} if $data->{user}->{'authentication-token'};
} else {
print $response->as_string;
die;
Expand Down