diff options
author | trizen <trizen@protonmail.com> | 2020-03-13 16:22:25 +0200 |
---|---|---|
committer | Jesús <heckyel@hyperbola.info> | 2020-03-14 12:03:00 -0500 |
commit | d2c82222588f72f2313c2d1658b30ac611d69d06 (patch) | |
tree | 9c3ac0902495c810b0d88212b848433f4a649aeb /lib/WWW/FairViewer.pm | |
parent | fa551c2d122cff235ef79e24833a1223fd7458d0 (diff) | |
download | fair-viewer-d2c82222588f72f2313c2d1658b30ac611d69d06.tar.lz fair-viewer-d2c82222588f72f2313c2d1658b30ac611d69d06.tar.xz fair-viewer-d2c82222588f72f2313c2d1658b30ac611d69d06.zip |
- 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=<URL>` option.
Signed-off-by: Jesús <heckyel@hyperbola.info>
Diffstat (limited to 'lib/WWW/FairViewer.pm')
-rw-r--r-- | lib/WWW/FairViewer.pm | 16 |
1 files changed, 13 insertions, 3 deletions
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 { |