From d2c82222588f72f2313c2d1658b30ac611d69d06 Mon Sep 17 00:00:00 2001 From: trizen Date: Fri, 13 Mar 2020 16:22:25 +0200 Subject: - Extract URLs in description from `descriptionHtml` field. (https://github.com/trizen/fair-viewer/issues/6) - Added the `--api-host=<...>` command-line option for changing the API host. - Fixed the `--info=` option. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jesús --- lib/WWW/FairViewer.pm | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'lib/WWW/FairViewer.pm') diff --git a/lib/WWW/FairViewer.pm b/lib/WWW/FairViewer.pm index d117b95..4b57f68 100644 --- a/lib/WWW/FairViewer.pm +++ b/lib/WWW/FairViewer.pm @@ -92,8 +92,8 @@ my %valid_options = ( access_token => {valid => [qr/^.{15}/], default => undef}, refresh_token => {valid => [qr/^.{15}/], default => undef}, - authentication_file => {valid => [qr/^./], default => undef}, - api_host => {valid => [qr{^https?://}], default => "https://invidio.us"}, + authentication_file => {valid => [qr/^./], default => undef}, + api_host => {valid => [qr{[-\w]+\.[-\w]+}], default => "https://invidio.us"}, # No input value allowed api_path => {valid => q[], default => '/api/v1/'}, @@ -135,6 +135,7 @@ sub basic_video_info_fields { title videoId description + descriptionHtml published publishedText viewCount @@ -493,7 +494,16 @@ sub _append_url_args { sub get_api_url { my ($self) = @_; - join('', $self->get_api_host, $self->get_api_path); + + my $host = $self->get_api_host; + + $host =~ s{/+\z}{}; # remove trailing '/' + + if ($host =~ m{^[-\w]+(?>\.[-\w]+)+\z}) { # no protocol specified + $host = 'https://' . $host; # default to HTTPS + } + + join('', $host, $self->get_api_path); } sub _simple_feeds_url { -- cgit v1.2.3