diff options
-rw-r--r-- | README.md | 3 | ||||
-rwxr-xr-x | bin/gtk-fair-viewer | 36 | ||||
-rw-r--r-- | lib/WWW/FairViewer.pm | 5 | ||||
-rw-r--r-- | lib/WWW/FairViewer/RegularExpressions.pm | 4 | ||||
-rw-r--r-- | lib/WWW/FairViewer/Utils.pm | 56 | ||||
-rwxr-xr-x | utils/auto_perltidy.sh | 6 | ||||
-rwxr-xr-x | utils/bak_cleaner.sh | 3 |
7 files changed, 52 insertions, 61 deletions
@@ -122,6 +122,9 @@ Alternatively, the following will automatically pick a random invidious instance The available instances are listed at: https://instances.invidio.us/ +### PIPE-VIEWER +[pipe-viewer](https://github.com/trizen/pipe-viewer) is an experimental fork of `straw-viewer` with the goal of parsing the YouTube website directly, and thus it may be a faster and more reliable alternative. + ### SUPPORT AND DOCUMENTATION After installing, you can find documentation with the following commands: diff --git a/bin/gtk-fair-viewer b/bin/gtk-fair-viewer index 401a47e..d6b9124 100755 --- a/bin/gtk-fair-viewer +++ b/bin/gtk-fair-viewer @@ -1239,14 +1239,16 @@ sub menu_popup { } # Recent channel activity events - { - my $item = 'Gtk3::ImageMenuItem'->new("Activities"); - $item->signal_connect(activate => sub { activities('channel', $channel_id) }); - $item->set_property(tooltip_text => "Show recent channel activity events"); - $item->set_image('Gtk3::Image'->new_from_icon_name("view-refresh-symbolic", q{menu})); - $item->show; - $author->append($item); - } +#<<< + #~ { + #~ my $item = 'Gtk3::ImageMenuItem'->new("Activities"); + #~ $item->signal_connect(activate => sub { activities('channel', $channel_id) }); + #~ $item->set_property(tooltip_text => "Show recent channel activity events"); + #~ $item->set_image('Gtk3::Image'->new_from_icon_name("view-refresh-symbolic", q{menu})); + #~ $item->show; + #~ $author->append($item); + #~ } +#>>> # Playlists created by this author { @@ -1259,14 +1261,16 @@ sub menu_popup { } # Liked videos by this author - { - my $item = 'Gtk3::ImageMenuItem'->new("Likes"); - $item->signal_connect(activate => sub { likes('channel', $channel_id) }); - $item->set_property(tooltip_text => "Show liked videos by this author"); - $item->set_image('Gtk3::Image'->new_from_icon_name("emblem-default-symbolic", q{menu})); - $item->show; - $author->append($item); - } +#<<< + #~ { + #~ my $item = 'Gtk3::ImageMenuItem'->new("Likes"); + #~ $item->signal_connect(activate => sub { likes('channel', $channel_id) }); + #~ $item->set_property(tooltip_text => "Show liked videos by this author"); + #~ $item->set_image('Gtk3::Image'->new_from_icon_name("emblem-default-symbolic", q{menu})); + #~ $item->show; + #~ $author->append($item); + #~ } +#>>> # Separator { diff --git a/lib/WWW/FairViewer.pm b/lib/WWW/FairViewer.pm index 224c415..31ed311 100644 --- a/lib/WWW/FairViewer.pm +++ b/lib/WWW/FairViewer.pm @@ -987,11 +987,6 @@ sub _extract_streaming_urls { $self->_check_streaming_urls($videoID, \@results); - if (grep { $_->{url} =~ /\bsc=yes\b/ } @results) { - say STDERR ":: Contains SC = yes" if $self->get_debug; - ##return; - } - # Keep only streams with contentLength > 0. @results = grep { $_->{itag} == 22 or (exists($_->{contentLength}) and $_->{contentLength} > 0) } @results; diff --git a/lib/WWW/FairViewer/RegularExpressions.pm b/lib/WWW/FairViewer/RegularExpressions.pm index 51e85cd..af61f94 100644 --- a/lib/WWW/FairViewer/RegularExpressions.pm +++ b/lib/WWW/FairViewer/RegularExpressions.pm @@ -27,9 +27,9 @@ our $non_digit_or_opt_re = qr{^(?!$range_num_re)(?>[0-9]{1,3}[^0-9]|[0-9]{4}|[^0 # Generic name my $generic_name_re = qr/[a-zA-Z0-9_.\-]{11,64}/; -our $valid_channel_id_re = qr{^(?:.*/channel/)?(?<channel_id>(?:\w+(?:[-.]++\w++)*|$generic_name_re))(?:/.*)?\z}; +our $valid_channel_id_re = qr{^(?:.*/(?:channel|c)/)?(?<channel_id>(?:[%\w]+(?:[-.]++[%\w]++)*|$generic_name_re))(?:/.*)?\z}; -our $get_channel_videos_id_re = qr{^.*/channel/(?<channel_id>(?:\w+(?:[-.]++\w++)*|$generic_name_re))}; +our $get_channel_videos_id_re = qr{^.*/(?:channel|c)/(?<channel_id>(?:[%\w]+(?:[-.]++[%\w]++)*|$generic_name_re))}; our $get_channel_playlists_id_re = qr{$get_channel_videos_id_re/playlists}; our $get_username_videos_re = qr{^.*/user/(?<username>[-.\w]+)}; diff --git a/lib/WWW/FairViewer/Utils.pm b/lib/WWW/FairViewer/Utils.pm index bd300b9..0aaac4f 100644 --- a/lib/WWW/FairViewer/Utils.pm +++ b/lib/WWW/FairViewer/Utils.pm @@ -225,7 +225,7 @@ sub has_entries { if (ref($result->{results}) eq 'HASH') { - foreach my $type(qw(comments videos playlists)) { + foreach my $type (qw(comments videos playlists)) { if (exists $result->{results}{$type}) { return scalar @{$result->{results}{$type}} > 0; } @@ -246,8 +246,8 @@ sub has_entries { return 0; } - return 1; # maybe? - #ref($result) eq 'HASH' and ($result->{results}{pageInfo}{totalResults} > 0); + return 1; # maybe? + #ref($result) eq 'HASH' and ($result->{results}{pageInfo}{totalResults} > 0); } =head2 normalize_video_title($title, $fat32safe) @@ -421,22 +421,6 @@ Get videoID. sub get_video_id { my ($self, $info) = @_; $info->{videoId}; - - #~ ref($info->{id}) eq 'HASH' ? $info->{id}{videoId} - #~ : exists($info->{snippet}{resourceId}{videoId}) ? $info->{snippet}{resourceId}{videoId} - #~ : exists($info->{contentDetails}{videoId}) ? $info->{contentDetails}{videoId} - #~ : exists($info->{contentDetails}{playlistItem}{resourceId}{videoId}) - #~ ? $info->{contentDetails}{playlistItem}{resourceId}{videoId} - #~ : exists($info->{contentDetails}{upload}{videoId}) ? $info->{contentDetails}{upload}{videoId} - #~ : do { - #~ my $id = $info->{id} // return undef; - - #~ if (length($id) != 11) { - #~ return undef; - #~ } - - #~ $id; - #~ }; } sub get_playlist_id { @@ -543,8 +527,8 @@ sub get_thumbnail_url { ref($info->{videoThumbnails}) eq 'ARRAY' or return ''; - my @thumbs = @{$info->{videoThumbnails}}; - my @wanted = grep{$_->{quality} eq $type} @thumbs; + my @thumbs = @{$info->{videoThumbnails}}; + my @wanted = grep { $_->{quality} eq $type } @thumbs; my $url; @@ -564,6 +548,7 @@ sub get_thumbnail_url { sub get_channel_title { my ($self, $info) = @_; + #$info->{snippet}{channelTitle} || $self->get_channel_id($info); $info->{author}; } @@ -585,18 +570,21 @@ sub get_comment_content { sub get_id { my ($self, $info) = @_; + #$info->{id}; $info->{videoId}; } sub get_channel_id { my ($self, $info) = @_; + #$info->{snippet}{resourceId}{channelId} // $info->{snippet}{channelId}; $info->{authorId}; } sub get_category_id { my ($self, $info) = @_; + #$info->{snippet}{resourceId}{categoryId} // $info->{snippet}{categoryId}; #"unknown"; $info->{genre} // 'Unknown'; @@ -630,6 +618,7 @@ sub get_category_name { sub get_publication_date { my ($self, $info) = @_; + #$self->format_date($info->{snippet}{publishedAt}); #$self->format_date require Time::Piece; @@ -639,7 +628,7 @@ sub get_publication_date { sub get_publication_age { my ($self, $info) = @_; - ($info->{publishedText} // '') =~ s/\sago\z//r;; + ($info->{publishedText} // '') =~ s/\sago\z//r; } sub get_publication_age_approx { @@ -672,6 +661,7 @@ sub get_publication_age_approx { sub get_duration { my ($self, $info) = @_; + #$self->format_duration($info->{contentDetails}{duration}); #$self->format_duration($info->{lengthSeconds}); $info->{lengthSeconds}; @@ -691,6 +681,7 @@ sub get_time { sub get_definition { my ($self, $info) = @_; + #uc($info->{contentDetails}{definition} // '-'); #...; "unknown"; @@ -698,6 +689,7 @@ sub get_definition { sub get_dimension { my ($self, $info) = @_; + #uc($info->{contentDetails}{dimension}); #...; "unknown"; @@ -705,6 +697,7 @@ sub get_dimension { sub get_caption { my ($self, $info) = @_; + #$info->{contentDetails}{caption}; #...; "unknown"; @@ -762,14 +755,14 @@ sub get_dislikes { sub get_comments { my ($self, $info) = @_; + #$info->{statistics}{commentCount}; 1; } { no strict 'refs'; - foreach my $pair ( - [playlist => {'playlist' => 1}], + foreach my $pair ([playlist => {'playlist' => 1}], [channel => {'channel' => 1}], [video => {'video' => 1, 'playlistItem' => 1}], [subscription => {'subscription' => 1}], @@ -784,19 +777,6 @@ sub get_comments { } exists $pair->[1]{$item->{type} // ''}; - - #~ if (ref($item->{id}) eq 'HASH') { - #~ if (exists $pair->[1]{$item->{id}{kind}}) { - #~ return 1; - #~ } - #~ } - #~ elsif (exists $item->{kind}) { - #~ if (exists $pair->[1]{$item->{kind}}) { - #~ return 1; - #~ } - #~ } - - #~ return; }; } @@ -805,7 +785,7 @@ sub get_comments { sub is_channelID { my ($self, $id) = @_; $id || return; - $id eq 'mine' or $id =~ /^UC[-a-zA-Z0-9_]{22}\z/; + $id =~ /^UC[-a-zA-Z0-9_]{22}\z/; } sub is_videoID { diff --git a/utils/auto_perltidy.sh b/utils/auto_perltidy.sh new file mode 100755 index 0000000..866dcfa --- /dev/null +++ b/utils/auto_perltidy.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +alias perltidy='perltidy -utf8 -l=127 -f -kbl=1 -bbb -bbc -bbs -b -ple -bt=2 -pt=2 -sbt=2 -bvt=0 -sbvt=1 -cti=1 -bar -lp -anl'; +which perltidy; +cd ..; +for i in $(git status | grep '^[[:cntrl:]]*modified:' | egrep 'bin/|\.(pm|t)$' | perl -nE 'say +(split)[-1]'); do echo $i; perltidy -b $i; done diff --git a/utils/bak_cleaner.sh b/utils/bak_cleaner.sh new file mode 100755 index 0000000..cb8340e --- /dev/null +++ b/utils/bak_cleaner.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +for i in $(git status | grep \.bak$ | perl -nE 'say +(split)[-1]'); do echo $i; rm $i; done |