mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
FB_CALLMONITOR: use online reverse search providers only for their corresponding country phone numbers (Forum: #71051)
git-svn-id: https://svn.fhem.de/fhem/trunk@14988 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
5840efa6c3
commit
7326aa295e
@ -1,5 +1,8 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
||||||
# Do not insert empty lines here, update check depends on it.
|
# Do not insert empty lines here, update check depends on it.
|
||||||
|
- changed: 72_FB_CALLMONITOR: reverse search only numbers for the specific
|
||||||
|
country (e.g. german numbers only via klicktel.de,dasoertliche.de,
|
||||||
|
austrian numbers via dasschnelle.at, swiss via search.ch)
|
||||||
- feature: 37_Spotify: new readings
|
- feature: 37_Spotify: new readings
|
||||||
- new: 93_Log2Syslog: V3.0.0, first release
|
- new: 93_Log2Syslog: V3.0.0, first release
|
||||||
- bugfix: 93_DbRep: V5.6.2, commandref revised
|
- bugfix: 93_DbRep: V5.6.2, commandref revised
|
||||||
|
@ -589,6 +589,7 @@ FB_CALLMONITOR_reverseSearch($$)
|
|||||||
my $result;
|
my $result;
|
||||||
my $status;
|
my $status;
|
||||||
my $invert_match = undef;
|
my $invert_match = undef;
|
||||||
|
my $country_code = AttrVal($name, "country-code", "0049");
|
||||||
my @attr_list = split("(,|\\|)", AttrVal($name, "reverse-search", ""));
|
my @attr_list = split("(,|\\|)", AttrVal($name, "reverse-search", ""));
|
||||||
|
|
||||||
foreach my $method (@attr_list)
|
foreach my $method (@attr_list)
|
||||||
@ -625,153 +626,186 @@ FB_CALLMONITOR_reverseSearch($$)
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Ask klicktel.de
|
# Ask klicktel.de
|
||||||
if($method eq "klicktel.de")
|
if($method eq "klicktel.de")
|
||||||
{
|
{
|
||||||
Log3 $name, 4, "FB_CALLMONITOR ($name) - using klicktel.de for reverse search of $number";
|
unless(($number =~ /^0[1-9]/ and $country_code eq "0049") or $number =~ /^0049/)
|
||||||
|
|
||||||
$result = GetFileFromURL("http://openapi.klicktel.de/searchapi/invers?key=0de6139a49055c37b9b2d7bb3933cb7b&number=".$number, 5, undef, 1);
|
|
||||||
if(not defined($result))
|
|
||||||
{
|
{
|
||||||
if(AttrVal($name, "reverse-search-cache", "0") eq "1")
|
Log3 $name, 4, "FB_CALLMONITOR ($name) - skip using klicktel.de for reverse search of $number because of non-german number";
|
||||||
{
|
|
||||||
$status = "timeout";
|
|
||||||
undef($result);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if($result =~ /"displayname":"([^"]*?)"/)
|
$number =~ s/^0049/0/; # remove country code
|
||||||
|
Log3 $name, 4, "FB_CALLMONITOR ($name) - using klicktel.de for reverse search of $number";
|
||||||
|
|
||||||
|
$result = GetFileFromURL("http://openapi.klicktel.de/searchapi/invers?key=0de6139a49055c37b9b2d7bb3933cb7b&number=".$number, 5, undef, 1);
|
||||||
|
if(not defined($result))
|
||||||
{
|
{
|
||||||
$invert_match = $1;
|
if(AttrVal($name, "reverse-search-cache", "0") eq "1")
|
||||||
$invert_match = FB_CALLMONITOR_html2txt($invert_match);
|
{
|
||||||
FB_CALLMONITOR_writeToCache($hash, $number, $invert_match);
|
$status = "timeout";
|
||||||
undef($result);
|
undef($result);
|
||||||
return $invert_match;
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if($result =~ /"displayname":"([^"]*?)"/)
|
||||||
|
{
|
||||||
|
$invert_match = $1;
|
||||||
|
$invert_match = FB_CALLMONITOR_html2txt($invert_match);
|
||||||
|
FB_CALLMONITOR_writeToCache($hash, $number, $invert_match);
|
||||||
|
undef($result);
|
||||||
|
return $invert_match;
|
||||||
|
}
|
||||||
|
|
||||||
|
$status = "unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
$status = "unknown";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Ask dasoertliche.de
|
# Ask dasoertliche.de
|
||||||
elsif($method eq "dasoertliche.de")
|
elsif($method eq "dasoertliche.de")
|
||||||
{
|
{
|
||||||
Log3 $name, 4, "FB_CALLMONITOR ($name) - using dasoertliche.de for reverse search of $number";
|
unless(($number =~ /^0[1-9]/ and $country_code eq "0049") or $number =~ /^0049/)
|
||||||
|
|
||||||
$result = GetFileFromURL("http://www1.dasoertliche.de/?form_name=search_inv&ph=".$number, 5, undef, 1);
|
|
||||||
if(not defined($result))
|
|
||||||
{
|
{
|
||||||
if(AttrVal($name, "reverse-search-cache", "0") eq "1")
|
Log3 $name, 4, "FB_CALLMONITOR ($name) - skip using dasoertliche.de for reverse search of $number because of non-german number";
|
||||||
{
|
|
||||||
$status = "timeout";
|
|
||||||
undef($result);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#Log 2, $result;
|
$number =~ s/^0049/0/; # remove country code
|
||||||
if($result =~ m,<a href="http\://.+?\.dasoertliche\.de.+?".+?class="name ".+?><span class="">(.+?)</span>,)
|
Log3 $name, 4, "FB_CALLMONITOR ($name) - using dasoertliche.de for reverse search of $number";
|
||||||
|
|
||||||
|
$result = GetFileFromURL("http://www1.dasoertliche.de/?form_name=search_inv&ph=".$number, 5, undef, 1);
|
||||||
|
if(not defined($result))
|
||||||
{
|
{
|
||||||
$invert_match = $1;
|
if(AttrVal($name, "reverse-search-cache", "0") eq "1")
|
||||||
$invert_match = FB_CALLMONITOR_html2txt($invert_match);
|
{
|
||||||
FB_CALLMONITOR_writeToCache($hash, $number, $invert_match);
|
$status = "timeout";
|
||||||
undef($result);
|
undef($result);
|
||||||
return $invert_match;
|
}
|
||||||
}
|
}
|
||||||
elsif(not $result =~ /wir konnten keine Treffer finden/)
|
else
|
||||||
{
|
{
|
||||||
Log3 $name, 3, "FB_CALLMONITOR ($name) - the reverse search result for $number could not be extracted from dasoertliche.de. Please contact the FHEM community.";
|
#Log 2, $result;
|
||||||
|
if($result =~ m,<a href="http\://.+?\.dasoertliche\.de.+?".+?class="name ".+?><span class="">(.+?)</span>,)
|
||||||
|
{
|
||||||
|
$invert_match = $1;
|
||||||
|
$invert_match = FB_CALLMONITOR_html2txt($invert_match);
|
||||||
|
FB_CALLMONITOR_writeToCache($hash, $number, $invert_match);
|
||||||
|
undef($result);
|
||||||
|
return $invert_match;
|
||||||
|
}
|
||||||
|
elsif(not $result =~ /wir konnten keine Treffer finden/)
|
||||||
|
{
|
||||||
|
Log3 $name, 3, "FB_CALLMONITOR ($name) - the reverse search result for $number could not be extracted from dasoertliche.de. Please contact the FHEM community.";
|
||||||
|
}
|
||||||
|
|
||||||
|
$status = "unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
$status = "unknown";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# SWITZERLAND ONLY!!! Ask search.ch
|
# SWITZERLAND ONLY!!! Ask search.ch
|
||||||
elsif($method eq "search.ch")
|
elsif($method eq "search.ch")
|
||||||
{
|
{
|
||||||
Log3 $name, 4, "FB_CALLMONITOR ($name) - using search.ch for reverse search of $number";
|
unless(($number =~ /^0[1-9]/ and $country_code eq "0041") or $number =~ /^0041/)
|
||||||
|
|
||||||
$result = GetFileFromURL("http://tel.search.ch/api/?key=b0b1207cb7c9d0048867de887aa9a4fd&maxnum=1&was=".$number, 5, undef, 1);
|
|
||||||
if(not defined($result))
|
|
||||||
{
|
{
|
||||||
if(AttrVal($name, "reverse-search-cache", "0") eq "1")
|
Log3 $name, 4, "FB_CALLMONITOR ($name) - skip using search.ch for reverse search of $number because of non-swiss number";
|
||||||
{
|
|
||||||
$status = "timeout";
|
|
||||||
undef($result);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#Log 2, $result;
|
$number =~ s/^0041/0/; # remove country code
|
||||||
if($result =~ m,<entry>(.+?)</entry>,s)
|
|
||||||
|
Log3 $name, 4, "FB_CALLMONITOR ($name) - using search.ch for reverse search of $number";
|
||||||
|
|
||||||
|
$result = GetFileFromURL("http://tel.search.ch/api/?key=b0b1207cb7c9d0048867de887aa9a4fd&maxnum=1&was=".$number, 5, undef, 1);
|
||||||
|
if(not defined($result))
|
||||||
{
|
{
|
||||||
my $xml = $1;
|
if(AttrVal($name, "reverse-search-cache", "0") eq "1")
|
||||||
|
|
||||||
$invert_match = "";
|
|
||||||
|
|
||||||
if($xml =~ m,<tel:firstname>(.+?)</tel:firstname>,)
|
|
||||||
{
|
{
|
||||||
$invert_match .= $1;
|
$status = "timeout";
|
||||||
|
undef($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($xml =~ m,<tel:name>(.+?)</tel:name>,)
|
|
||||||
{
|
|
||||||
$invert_match .= " $1";
|
|
||||||
}
|
|
||||||
|
|
||||||
if($xml =~ m,<tel:occupation>(.+?)</tel:occupation>,)
|
|
||||||
{
|
|
||||||
$invert_match .= ", $1";
|
|
||||||
}
|
|
||||||
|
|
||||||
$invert_match = FB_CALLMONITOR_html2txt($invert_match);
|
|
||||||
FB_CALLMONITOR_writeToCache($hash, $number, $invert_match);
|
|
||||||
undef($result);
|
|
||||||
return $invert_match;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
$status = "unknown";
|
{
|
||||||
|
#Log 2, $result;
|
||||||
|
if($result =~ m,<entry>(.+?)</entry>,s)
|
||||||
|
{
|
||||||
|
my $xml = $1;
|
||||||
|
|
||||||
|
$invert_match = "";
|
||||||
|
|
||||||
|
if($xml =~ m,<tel:firstname>(.+?)</tel:firstname>,)
|
||||||
|
{
|
||||||
|
$invert_match .= $1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($xml =~ m,<tel:name>(.+?)</tel:name>,)
|
||||||
|
{
|
||||||
|
$invert_match .= " $1";
|
||||||
|
}
|
||||||
|
|
||||||
|
if($xml =~ m,<tel:occupation>(.+?)</tel:occupation>,)
|
||||||
|
{
|
||||||
|
$invert_match .= ", $1";
|
||||||
|
}
|
||||||
|
|
||||||
|
$invert_match = FB_CALLMONITOR_html2txt($invert_match);
|
||||||
|
FB_CALLMONITOR_writeToCache($hash, $number, $invert_match);
|
||||||
|
undef($result);
|
||||||
|
return $invert_match;
|
||||||
|
}
|
||||||
|
|
||||||
|
$status = "unknown";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Austria ONLY!!! Ask dasschnelle.at
|
# Austria ONLY!!! Ask dasschnelle.at
|
||||||
elsif($method eq "dasschnelle.at")
|
elsif($method eq "dasschnelle.at")
|
||||||
{
|
{
|
||||||
Log3 $name, 4, "FB_CALLMONITOR ($name) - using dasschnelle.at for reverse search of $number";
|
unless(($number =~ /^0[1-9]/ and $country_code eq "0043") or $number =~ /^0043/)
|
||||||
|
|
||||||
$result = GetFileFromURL("http://www.dasschnelle.at/ergebnisse?what=".$number."&where=&rubrik=0&bezirk=0&orderBy=Standard&mapsearch=false", 5, undef, 1);
|
|
||||||
if(not defined($result))
|
|
||||||
{
|
{
|
||||||
if(AttrVal($name, "reverse-search-cache", "0") eq "1")
|
Log3 $name, 4, "FB_CALLMONITOR ($name) - skip using dasschnelle.at for reverse search of $number because of non-swiss number";
|
||||||
{
|
|
||||||
$status = "timeout";
|
|
||||||
undef($result);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#Log 2, $result;
|
$number =~ s/^0043/0/; # remove country code
|
||||||
if($result =~ /"name"\s*:\s*"([^"]+)",/)
|
Log3 $name, 4, "FB_CALLMONITOR ($name) - using dasschnelle.at for reverse search of $number";
|
||||||
{
|
|
||||||
$invert_match = "";
|
|
||||||
|
|
||||||
while($result =~ /"name"\s*:\s*"([^"]+)",/g)
|
$result = GetFileFromURL("http://www.dasschnelle.at/ergebnisse?what=".$number."&where=&rubrik=0&bezirk=0&orderBy=Standard&mapsearch=false", 5, undef, 1);
|
||||||
|
if(not defined($result))
|
||||||
|
{
|
||||||
|
if(AttrVal($name, "reverse-search-cache", "0") eq "1")
|
||||||
{
|
{
|
||||||
$invert_match = $1 if(length($1) > length($invert_match));
|
$status = "timeout";
|
||||||
|
undef($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
$invert_match = FB_CALLMONITOR_html2txt($invert_match);
|
|
||||||
FB_CALLMONITOR_writeToCache($hash, $number, $invert_match);
|
|
||||||
undef($result);
|
|
||||||
return $invert_match;
|
|
||||||
}
|
}
|
||||||
elsif(not $result =~ /Es wurden keine passenden Eintr.ge gefunden/)
|
else
|
||||||
{
|
{
|
||||||
Log3 $name, 3, "FB_CALLMONITOR ($name) - the reverse search result for $number could not be extracted from dasschnelle.at. Please contact the FHEM community.";
|
#Log 2, $result;
|
||||||
|
if($result =~ /"name"\s*:\s*"([^"]+)",/)
|
||||||
|
{
|
||||||
|
$invert_match = "";
|
||||||
|
|
||||||
|
while($result =~ /"name"\s*:\s*"([^"]+)",/g)
|
||||||
|
{
|
||||||
|
$invert_match = $1 if(length($1) > length($invert_match));
|
||||||
|
}
|
||||||
|
|
||||||
|
$invert_match = FB_CALLMONITOR_html2txt($invert_match);
|
||||||
|
FB_CALLMONITOR_writeToCache($hash, $number, $invert_match);
|
||||||
|
undef($result);
|
||||||
|
return $invert_match;
|
||||||
|
}
|
||||||
|
elsif(not $result =~ /Ihre Suche nach .* war erfolglos/)
|
||||||
|
{
|
||||||
|
Log3 $name, 3, "FB_CALLMONITOR ($name) - the reverse search result for $number could not be extracted from dasschnelle.at. Please contact the FHEM community.";
|
||||||
|
}
|
||||||
|
|
||||||
|
$status = "unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
$status = "unknown";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user