Skip to content

Commit

Permalink
- Added the ignore_av1 config-option. (disabled by default)
Browse files Browse the repository at this point in the history
Also available as a command-line argument:

	youtube-viewer --ignore-av1

When enabled, videos in AV1 format will be ignored. Recommended to be enabled on slow hardware.
  • Loading branch information
trizen committed Oct 10, 2020
1 parent fd94a61 commit 404fe98
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 125 deletions.
32 changes: 15 additions & 17 deletions bin/gtk2-youtube-viewer
Expand Up @@ -186,6 +186,7 @@ my %CONFIG = (
dash_segmented => 1, # may load slow
prefer_mp4 => 0,
prefer_av1 => 0,
ignore_av1 => 0,
maxResults => 10,
hfr => 1,
resolution => 'best',
Expand Down Expand Up @@ -814,7 +815,8 @@ sub apply_configuration {
publishedAfter publishedBefore
regionCode videoCategoryId
debug http_proxy user_agent
timeout cookie_file
timeout cookie_file prefer_mp4
prefer_av1
)
) {

Expand All @@ -835,12 +837,6 @@ sub apply_configuration {
# Enable/disable thumbnails
$thumbs_checkbutton->set_active($CONFIG{show_thumbs});

# Prefer MP4 over WEBM
$yv_obj->set_prefer_mp4($CONFIG{prefer_mp4} ? 1 : 0);

# Prefer AV1 over WEBM
$yv_obj->set_prefer_av1($CONFIG{prefer_av1} ? 1 : 0);

# Set the "More options" expander
$more_options_expander->set_expanded($CONFIG{active_more_options_expander});

Expand Down Expand Up @@ -1332,7 +1328,7 @@ set_text(
CTRL+U : show the saved user-list
CTRL+D : show more video details for a selected video
CTRL+W : show the warnings window
CTRL+G : show videos favorited by the author of a selected video
CTRL+G : show favorite videos of the author of a selected video
CTRL+R : show related videos for a selected video
CTRL+M : show videos from the author of a selected video
CTRL+K : show playlists from the author of a selected video
Expand Down Expand Up @@ -2909,15 +2905,17 @@ sub get_streaming_url {
require WWW::YoutubeViewer::Itags;
state $yv_itags = WWW::YoutubeViewer::Itags->new();

my ($streaming, $resolution) =
$yv_itags->find_streaming_url(
urls => $urls,
hfr => $CONFIG{hfr},
resolution => $CONFIG{resolution},
dash => $CONFIG{dash_support},
dash_mp4_audio => $CONFIG{dash_mp4_audio},
dash_segmented => $CONFIG{dash_segmented},
);
my ($streaming, $resolution) = $yv_itags->find_streaming_url(
urls => $urls,

hfr => $CONFIG{hfr},
ignore_av1 => $CONFIG{ignore_av1},
resolution => $CONFIG{resolution},

dash => $CONFIG{dash_support},
dash_mp4_audio => $CONFIG{dash_mp4_audio},
dash_segmented => $CONFIG{dash_segmented},
);

return {
streaming => $streaming,
Expand Down
32 changes: 15 additions & 17 deletions bin/gtk3-youtube-viewer
Expand Up @@ -187,6 +187,7 @@ my %CONFIG = (
dash_segmented => 1, # may load slow
prefer_mp4 => 0,
prefer_av1 => 0,
ignore_av1 => 0,
maxResults => 10,
hfr => 1,
resolution => 'best',
Expand Down Expand Up @@ -886,7 +887,8 @@ sub apply_configuration {
publishedAfter publishedBefore
regionCode videoCategoryId
debug http_proxy user_agent
timeout cookie_file
timeout cookie_file prefer_mp4
prefer_av1
)
) {

Expand All @@ -907,12 +909,6 @@ sub apply_configuration {
# Enable/disable thumbnails
$thumbs_checkbutton->set_active($CONFIG{show_thumbs});

# Prefer MP4 over WEBM
$yv_obj->set_prefer_mp4($CONFIG{prefer_mp4} ? 1 : 0);

# Prefer AV1 over WEBM
$yv_obj->set_prefer_av1($CONFIG{prefer_av1} ? 1 : 0);

# Set the "More options" expander
$more_options_expander->set_expanded($CONFIG{active_more_options_expander});

Expand Down Expand Up @@ -1404,7 +1400,7 @@ set_text(
CTRL+U : show the saved user-list
CTRL+D : show more video details for a selected video
CTRL+W : show the warnings window
CTRL+G : show videos favorited by the author of a selected video
CTRL+G : show favorite videos of the author of a selected video
CTRL+R : show related videos for a selected video
CTRL+M : show videos from the author of a selected video
CTRL+K : show playlists from the author of a selected video
Expand Down Expand Up @@ -3055,15 +3051,17 @@ sub get_streaming_url {
require WWW::YoutubeViewer::Itags;
state $yv_itags = WWW::YoutubeViewer::Itags->new();

my ($streaming, $resolution) =
$yv_itags->find_streaming_url(
urls => $urls,
hfr => $CONFIG{hfr},
resolution => $CONFIG{resolution},
dash => $CONFIG{dash_support},
dash_mp4_audio => $CONFIG{dash_mp4_audio},
dash_segmented => $CONFIG{dash_segmented},
);
my ($streaming, $resolution) = $yv_itags->find_streaming_url(
urls => $urls,

hfr => $CONFIG{hfr},
ignore_av1 => $CONFIG{ignore_av1},
resolution => $CONFIG{resolution},

dash => $CONFIG{dash_support},
dash_mp4_audio => $CONFIG{dash_mp4_audio},
dash_segmented => $CONFIG{dash_segmented},
);

return {
streaming => $streaming,
Expand Down
38 changes: 18 additions & 20 deletions bin/youtube-viewer
Expand Up @@ -241,6 +241,7 @@ my %CONFIG = (
skip_if_exists => 1,
prefer_mp4 => 0,
prefer_av1 => 0,
ignore_av1 => 0,
fat32safe => $constant{win32},
fullscreen => 0,
results_with_details => 0,
Expand Down Expand Up @@ -692,7 +693,7 @@ usage: $execname [options] ([url] | [keywords])
* Videos
-uv --uploads=s : list videos uploaded by a specific channel or user
-pv --popular=s : list the most popular videos from a specific channel
-uf --favorites=s : list the videos favorited by a specific user
-uf --favorites=s : list the favorite videos of a specific user
-id --videoids=s,s : play YouTube videos by their IDs
-rv --related=s : show related videos for a video ID or URL
-sv --search-videos : search for YouTube videos (default mode)
Expand Down Expand Up @@ -750,7 +751,7 @@ usage: $execname [options] ([url] | [keywords])
* [GET] Personal
-U --uploads:s : show the uploads from your channel *
-P --playlists:s : show the playlists from your channel *
-F --favorites:s : show the latest favorited videos *
-F --favorites:s : show the latest favorite videos *
-S --subscriptions:s : show the subscribed channels *
-SV --subs-videos:s : show the subscription videos (slow) *
--subs-order=s : change the subscription order
Expand Down Expand Up @@ -814,6 +815,7 @@ usage: $execname [options] ([url] | [keywords])
--confirm! : show a confirmation message after each play
--prefer-mp4! : prefer videos in MP4 format, instead of WEBM
--prefer-av1! : prefer videos in AV1 format, instead of WEBM
--ignore-av1! : ignore videos in AV1 format
* Closed-captions
--get-captions! : download closed-captions for videos
Expand Down Expand Up @@ -1143,7 +1145,8 @@ sub apply_configuration {
safeSearch regionCode debug hl
http_proxy page comments_order
subscriptions_order user_agent
cookie_file timeout
cookie_file timeout prefer_mp4
prefer_av1
)
) {

Expand Down Expand Up @@ -1172,14 +1175,6 @@ sub apply_configuration {
}
}

if (defined $opt->{prefer_mp4}) {
$yv_obj->set_prefer_mp4(delete($opt->{prefer_mp4}) ? 1 : 0);
}

if (defined $opt->{prefer_av1}) {
$yv_obj->set_prefer_av1(delete($opt->{prefer_av1}) ? 1 : 0);
}

if (defined $opt->{hd}) {
$yv_obj->set_videoDefinition(delete($opt->{hd}) ? 'high' : 'any');
}
Expand Down Expand Up @@ -1635,6 +1630,7 @@ sub parse_arguments {

'prefer-mp4!' => \$opt{prefer_mp4},
'prefer-av1!' => \$opt{prefer_av1},
'ignore-av1!' => \$opt{ignore_av1},

'custom-layout!' => \$opt{custom_layout},
'custom-layout-format=s' => \$opt{custom_layout_format},
Expand Down Expand Up @@ -3124,15 +3120,17 @@ sub get_streaming_url {
$dash = $opt{merge_into_mkv} ? 1 : 0;
}

my ($streaming, $resolution) =
$yv_itags->find_streaming_url(
urls => $urls,
resolution => ($opt{novideo} ? 'audio' : $opt{resolution}),
hfr => $opt{hfr},
dash => $dash,
dash_mp4_audio => ($opt{novideo} ? 1 : $opt{dash_mp4_audio}),
dash_segmented => ($opt{download_video} ? 0 : $opt{dash_segmented}),
);
my ($streaming, $resolution) = $yv_itags->find_streaming_url(
urls => $urls,
resolution => ($opt{novideo} ? 'audio' : $opt{resolution}),

hfr => $opt{hfr},
ignore_av1 => $opt{ignore_av1},

dash => $dash,
dash_mp4_audio => ($opt{novideo} ? 1 : $opt{dash_mp4_audio}),
dash_segmented => ($opt{download_video} ? 0 : $opt{dash_segmented}),
);

return {
streaming => $streaming,
Expand Down

0 comments on commit 404fe98

Please sign in to comment.