| 1 | =head1 NAME | ||
| 2 | |||
| 3 | StreamFinder::Blogger - Fetch actual raw streamable URLs from Blogger / Blogspot videos. | ||
| 4 | |||
| 5 | =head1 AUTHOR | ||
| 6 | |||
| 7 | This module is Copyright (C) 2017-2021 by | ||
| 8 | |||
| 9 | Jim Turner, C<< <turnerjw784 at yahoo.com> >> | ||
| 10 | |||
| 11 | Email: turnerjw784@yahoo.com | ||
| 12 | |||
| 13 | All rights reserved. | ||
| 14 | |||
| 15 | You may distribute this module under the terms of either the GNU General | ||
| 16 | Public License or the Artistic License, as specified in the Perl README | ||
| 17 | file. | ||
| 18 | |||
| 19 | =head1 SYNOPSIS | ||
| 20 | |||
| 21 | #!/usr/bin/perl | ||
| 22 | |||
| 23 | use strict; | ||
| 24 | |||
| 25 | use StreamFinder::Blogger; | ||
| 26 | |||
| 27 | die "..usage: $0 URL\n" unless ($ARGV[0]); | ||
| 28 | |||
| 29 | my $video = new StreamFinder::Blogger($ARGV[0]); | ||
| 30 | |||
| 31 | die "Invalid URL or no streams found!\n" unless ($video); | ||
| 32 | |||
| 33 | my $firstStream = $video->get(); | ||
| 34 | |||
| 35 | print "First Stream URL=$firstStream\n"; | ||
| 36 | |||
| 37 | my $url = $video->getURL(); | ||
| 38 | |||
| 39 | print "Stream URL=$url\n"; | ||
| 40 | |||
| 41 | my $videoTitle = $video->getTitle(); | ||
| 42 | |||
| 43 | print "Title=$videoTitle\n"; | ||
| 44 | |||
| 45 | my $videoDescription = $video->getTitle('desc'); | ||
| 46 | |||
| 47 | print "Description=$videoDescription\n"; | ||
| 48 | |||
| 49 | my $videoID = $video->getID(); | ||
| 50 | |||
| 51 | print "Video ID=$videoID\n"; | ||
| 52 | |||
| 53 | my $artist = $video->{'artist'}; | ||
| 54 | |||
| 55 | print "Artist=$artist\n" if ($artist); | ||
| 56 | |||
| 57 | my $albumartist = $video->{'albumartist'}; | ||
| 58 | |||
| 59 | print "Album Artist=$albumartist\n" if ($albumartist); | ||
| 60 | |||
| 61 | my $icon_url = $video->getIconURL(); | ||
| 62 | |||
| 63 | if ($icon_url) { #SAVE THE ICON TO A TEMP. FILE: | ||
| 64 | |||
| 65 | my ($image_ext, $icon_image) = $video->getIconData(); | ||
| 66 | |||
| 67 | if ($icon_image && open IMGOUT, ">/tmp/${videoID}.$image_ext") { | ||
| 68 | |||
| 69 | binmode IMGOUT; | ||
| 70 | |||
| 71 | print IMGOUT $icon_image; | ||
| 72 | |||
| 73 | close IMGOUT; | ||
| 74 | |||
| 75 | } | ||
| 76 | |||
| 77 | } | ||
| 78 | |||
| 79 | my $stream_count = $video->count(); | ||
| 80 | |||
| 81 | print "--Stream count=$stream_count=\n"; | ||
| 82 | |||
| 83 | my @streams = $video->get(); | ||
| 84 | |||
| 85 | foreach my $s (@streams) { | ||
| 86 | |||
| 87 | print "------ stream URL=$s=\n"; | ||
| 88 | |||
| 89 | } | ||
| 90 | |||
| 91 | =head1 DESCRIPTION | ||
| 92 | |||
| 93 | StreamFinder::Blogger accepts a valid full Blogger video URL on | ||
| 94 | blogger.com and returns the actual stream URL, ID, and cover art icon | ||
| 95 | for that video. The purpose is that one needs this URL in order to have | ||
| 96 | the option to stream the video in one's own choice of media player | ||
| 97 | software rather than using their web browser and accepting any / all flash, | ||
| 98 | ads, javascript, cookies, trackers, web-bugs, and other crapware that can | ||
| 99 | come with that method of play. The author uses his own custom all-purpose | ||
| 100 | media player called "fauxdacious" (his custom hacked version of the | ||
| 101 | open-source "audacious" audio player). "fauxdacious" incorporates this | ||
| 102 | module to decode and play blogger.com videos. This is a submodule of the | ||
| 103 | general StreamFinder module. | ||
| 104 | |||
| 105 | Depends: | ||
| 106 | |||
| 107 | L<URI::Escape>, L<HTML::Entities>, L<LWP::UserAgent> | ||
| 108 | |||
| 109 | The separate application program: youtube-dl, or a compatable program | ||
| 110 | such as yt-dlp (only if wishing to use the I<-youtube> option). | ||
| 111 | |||
| 112 | =head1 SUBROUTINES/METHODS | ||
| 113 | |||
| 114 | =over 4 | ||
| 115 | |||
| 116 | =item B<new>(I<url> [, I<-youtube> => yes|no|first|last|only ] | ||
| 117 | [, I<-keep> => "type1,type2?..." | [type1,type2?...] ] | ||
| 118 | [, I<-secure> [ => 0|1 ]] [, I<-debug> [ => 0|1|2 ]]) | ||
| 119 | |||
| 120 | Accepts a blogger.com video URL and creates and returns a new video object, | ||
| 121 | or I<undef> if the URL is not a valid Blogger video or no streams are found. | ||
| 122 | The URL can be the full URL, ie. https://www.blogger.com/B<video-id>, | ||
| 123 | or just I<video-id>. | ||
| 124 | |||
| 125 | The optional I<-keep> argument can be either a comma-separated string or an | ||
| 126 | array reference ([...]) of stream types to keep (include) and returned in order | ||
| 127 | specified (type1, type2...). Each "type" can be one of: extension (ie. m4a, | ||
| 128 | mp4, etc.), "playlist", "stream", or ("any" or "all"). | ||
| 129 | |||
| 130 | DEFAULT I<-keep> list is: 'm4a,mpd,stream,all', meaning that all m4a streams | ||
| 131 | followed by all "mpd" streams, followed by non-playlists, followed by all | ||
| 132 | remaining (playlists: (pls) streams. More than one value can be specified to | ||
| 133 | control order of search. | ||
| 134 | |||
| 135 | NOTE: I<-keep> is ignored if I<-youtube> is set to "I<only>". | ||
| 136 | |||
| 137 | The optional I<-youtube> argument can be set to "I<yes>" or "I<last>" - also | ||
| 138 | include streams youtube-dl finds; "I<no>" - only include streams embedded in | ||
| 139 | the video's blogger.com page, unless none are found; "I<only>" - only include | ||
| 140 | streams youtube-dl finds; or "I<first>" - include streams youtube-dl | ||
| 141 | finds first. Default is B<"no">. | ||
| 142 | |||
| 143 | |||
| 144 | The optional I<-secure> argument can be either 0 or 1 (I<false> or I<true>). | ||
| 145 | If 1 then only secure ("https://") streams will be returned. | ||
| 146 | |||
| 147 | DEFAULT I<-secure> is 0 (false) - return all streams (http and https). | ||
| 148 | |||
| 149 | Additional options: | ||
| 150 | |||
| 151 | Certain youtube-dl (L<StreamFinder::Youtube>) configuration options, | ||
| 152 | namely I<format>, I<formatonly>, I<youtube-dl-args>, and I<youtube-dl-add-args> | ||
| 153 | can be overridden here by specifying I<youtube-format>, I<youtube-formatonly>, | ||
| 154 | I<youtube-dl-args>, and I<youtube-dl-add-args> arguments respectively. It is | ||
| 155 | however, recommended to specify these in the Blogger-specific | ||
| 156 | configuration file (see B<CONFIGURATION FILES> below. NOTE: These are only | ||
| 157 | applicable when using the option: I<-youtube> => I<yes|only|top>, etc. | ||
| 158 | |||
| 159 | I<-log> => "I<logfile>" | ||
| 160 | |||
| 161 | Specify path to a log file. If a valid and writable file is specified, A line | ||
| 162 | will be appended to this file every time one or more streams is successfully | ||
| 163 | fetched for a url. | ||
| 164 | |||
| 165 | DEFAULT I<-none-> (no logging). | ||
| 166 | |||
| 167 | I<-logfmt> specifies a format string for lines written to the log file. | ||
| 168 | |||
| 169 | DEFAULT "I<[time] [url] - [site]: [title] ([total])>". | ||
| 170 | |||
| 171 | The valid field I<[variables]> are: [stream]: The url of the first/best | ||
| 172 | stream found. [site]: The site name (Blogger). [url]: The url searched | ||
| 173 | for streams. [time]: Perl timestamp when the line was logged. [title], | ||
| 174 | [artist], [album], [description], [year], [genre], [total], [albumartist]: | ||
| 175 | The corresponding field data returned (or "I<-na->", if no value). | ||
| 176 | |||
| 177 | =item $video->B<get>() | ||
| 178 | |||
| 179 | Returns an array of strings representing all stream URLs found. | ||
| 180 | |||
| 181 | =item $video->B<getURL>([I<options>]) | ||
| 182 | |||
| 183 | Similar to B<get>() except it only returns a single stream representing | ||
| 184 | the first valid stream found. | ||
| 185 | |||
| 186 | Current options are: I<"random">, I<"nopls">, and I<"noplaylists">. | ||
| 187 | By default, the first ("best"?) stream is returned. If I<"random"> is | ||
| 188 | specified, then a random one is selected from the list of streams found. | ||
| 189 | If I<"nopls"> is specified, and the stream to be returned is a ".pls" | ||
| 190 | playlist, it is first fetched and the first entry (or a random entry if | ||
| 191 | I<"random"> is specified) is returned. This is needed by Fauxdacious | ||
| 192 | Mediaplayer. If I<"noplaylists"> is specified, and the stream to be returned | ||
| 193 | is a "playlist" (either .pls or .m3u? extension), it is first fetched and the | ||
| 194 | first entry (or a random entry if I<"random"> is specified) in the playlist | ||
| 195 | is returned. | ||
| 196 | |||
| 197 | =item $video->B<count>() | ||
| 198 | |||
| 199 | Returns the number of streams found for the video. | ||
| 200 | |||
| 201 | =item $video->B<getID>() | ||
| 202 | |||
| 203 | Returns the video's Blogger ID (alphanumeric). | ||
| 204 | |||
| 205 | =item $video->B<getTitle>(['desc']) | ||
| 206 | |||
| 207 | Returns the video's title, or (long description). | ||
| 208 | |||
| 209 | =item $video->B<getIconURL>() | ||
| 210 | |||
| 211 | Returns the URL for the video's "cover art" icon image, if any. | ||
| 212 | |||
| 213 | =item $video->B<getIconData>() | ||
| 214 | |||
| 215 | Returns a two-element array consisting of the extension (ie. "png", | ||
| 216 | "gif", "jpeg", etc.) and the actual icon image (binary data), if any. | ||
| 217 | |||
| 218 | =item $video->B<getImageURL>() | ||
| 219 | |||
| 220 | Returns the URL for the video's "cover art" banner image, which for | ||
| 221 | Blogger videos is always the icon image, as Blogger does not | ||
| 222 | support a separate banner image at this time. | ||
| 223 | |||
| 224 | =item $video->B<getImageData>() | ||
| 225 | |||
| 226 | Returns a two-element array consisting of the extension (ie. "png", | ||
| 227 | "gif", "jpeg", etc.) and the actual video's banner image (binary data). | ||
| 228 | |||
| 229 | =item $video->B<getType>() | ||
| 230 | |||
| 231 | Returns the video's type ("Blogger"). | ||
| 232 | |||
| 233 | =back | ||
| 234 | |||
| 235 | =head1 CONFIGURATION FILES | ||
| 236 | |||
| 237 | The default root location directory for StreamFinder configuration files | ||
| 238 | is "~/.config/StreamFinder". To use an alternate location directory, | ||
| 239 | specify it in the "I<STREAMFINDER>" environment variable, ie.: | ||
| 240 | B<$ENV{STREAMFINDER} = "/etc/StreamFinder">. | ||
| 241 | |||
| 242 | =over 4 | ||
| 243 | |||
| 244 | =item ~/.config/StreamFinder/Blogger/config | ||
| 245 | |||
| 246 | Optional text file for specifying various configuration options | ||
| 247 | for a specific site (submodule). Each option is specified on a | ||
| 248 | separate line in the format below: | ||
| 249 | NOTE: Do not follow the lines with a semicolon, comma, or any other | ||
| 250 | separator. Non-numeric I<values> should be surrounded with quotes, either | ||
| 251 | single or double. Blank lines and lines beginning with a "#" sign as | ||
| 252 | their first non-blank character are ignored as comments. | ||
| 253 | |||
| 254 | 'option' => 'value' [,] | ||
| 255 | |||
| 256 | and the options are loaded into a hash used only by the specific | ||
| 257 | (submodule) specified. Valid options include | ||
| 258 | I<-debug> => [0|1|2] and most of the L<LWP::UserAgent> options. | ||
| 259 | |||
| 260 | Options specified here override any specified in | ||
| 261 | I<~/.config/StreamFinder/config>. | ||
| 262 | |||
| 263 | Among options valid for Blogger streams is the I<-keep> and | ||
| 264 | I<-youtube> options described in the B<new()> function. Also, | ||
| 265 | various youtube-dl (L<StreamFinder::Youtube>) configuration options, | ||
| 266 | namely I<format>, I<formatonly>, I<youtube-dl-args>, and | ||
| 267 | I<youtube-dl-add-args> can be overridden here by specifying | ||
| 268 | I<youtube-format>, I<youtube-formatonly>, I<youtube-dl-args>, and | ||
| 269 | I<youtube-dl-add-args> arguments respectively. NOTE: These are only | ||
| 270 | applicable when using the option: I<-youtube> => I<yes|only|top>, etc. | ||
| 271 | |||
| 272 | =item ~/.config/StreamFinder/config | ||
| 273 | |||
| 274 | Optional text file for specifying various configuration options. | ||
| 275 | Each option is specified on a separate line in the format below: | ||
| 276 | |||
| 277 | 'option' => 'value' [,] | ||
| 278 | |||
| 279 | and the options are loaded into a hash used by all sites | ||
| 280 | (submodules) that support them. Valid options include | ||
| 281 | I<-debug> => [0|1|2] and most of the L<LWP::UserAgent> options. | ||
| 282 | |||
| 283 | =back | ||
| 284 | |||
| 285 | NOTE: Options specified in the options parameter list of the I<new()> | ||
| 286 | function will override those corresponding options specified in these files. | ||
| 287 | |||
| 288 | =head1 KEYWORDS | ||
| 289 | |||
| 290 | blogger | ||
| 291 | |||
| 292 | =head1 DEPENDENCIES | ||
| 293 | |||
| 294 | L<URI::Escape>, L<HTML::Entities>, L<LWP::UserAgent> | ||
| 295 | |||
| 296 | =head1 RECCOMENDS | ||
| 297 | |||
| 298 | youtube-dl (or yt-dlp, or other compatable program) | ||
| 299 | |||
| 300 | wget | ||
| 301 | |||
| 302 | =head1 BUGS | ||
| 303 | |||
| 304 | Please report any bugs or feature requests to C<bug-streamFinder-blogger at rt.cpan.org>, or through | ||
| 305 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=StreamFinder-Blogger>. I will be notified, and then you'll | ||
| 306 | automatically be notified of progress on your bug as I make changes. | ||
| 307 | |||
| 308 | =head1 SUPPORT | ||
| 309 | |||
| 310 | You can find documentation for this module with the perldoc command. | ||
| 311 | |||
| 312 | perldoc StreamFinder::Blogger | ||
| 313 | |||
| 314 | You can also look for information at: | ||
| 315 | |||
| 316 | =over 4 | ||
| 317 | |||
| 318 | =item * RT: CPAN's request tracker (report bugs here) | ||
| 319 | |||
| 320 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=StreamFinder-Blogger> | ||
| 321 | |||
| 322 | =item * AnnoCPAN: Annotated CPAN documentation | ||
| 323 | |||
| 324 | L<http://annocpan.org/dist/StreamFinder-Blogger> | ||
| 325 | |||
| 326 | =item * CPAN Ratings | ||
| 327 | |||
| 328 | L<http://cpanratings.perl.org/d/StreamFinder-Blogger> | ||
| 329 | |||
| 330 | =item * Search CPAN | ||
| 331 | |||
| 332 | L<http://search.cpan.org/dist/StreamFinder-Blogger/> | ||
| 333 | |||
| 334 | =back | ||
| 335 | |||
| 336 | =head1 LICENSE AND COPYRIGHT | ||
| 337 | |||
| 338 | Copyright 2017-2021 Jim Turner. | ||
| 339 | |||
| 340 | This program is free software; you can redistribute it and/or modify it | ||
| 341 | under the terms of the the Artistic License (2.0). You may obtain a | ||
| 342 | copy of the full license at: | ||
| 343 | |||
| 344 | L<http://www.perlfoundation.org/artistic_license_2_0> | ||
| 345 | |||
| 346 | Any use, modification, and distribution of the Standard or Modified | ||
| 347 | Versions is governed by this Artistic License. By using, modifying or | ||
| 348 | distributing the Package, you accept this license. Do not use, modify, | ||
| 349 | or distribute the Package, if you do not accept this license. | ||
| 350 | |||
| 351 | If your Modified Version has been derived from a Modified Version made | ||
| 352 | by someone other than you, you are nevertheless required to ensure that | ||
| 353 | your Modified Version complies with the requirements of this license. | ||
| 354 | |||
| 355 | This license does not grant you the right to use any trademark, service | ||
| 356 | mark, tradename, or logo of the Copyright Holder. | ||
| 357 | |||
| 358 | This license includes the non-exclusive, worldwide, free-of-charge | ||
| 359 | patent license to make, have made, use, offer to sell, sell, import and | ||
| 360 | otherwise transfer the Package with respect to any patent claims | ||
| 361 | licensable by the Copyright Holder that are necessarily infringed by the | ||
| 362 | Package. If you institute patent litigation (including a cross-claim or | ||
| 363 | counterclaim) against any party alleging that the Package constitutes | ||
| 364 | direct or contributory patent infringement, then this Artistic License | ||
| 365 | to you shall terminate on the date that such litigation is filed. | ||
| 366 | |||
| 367 | Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER | ||
| 368 | AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. | ||
| 369 | THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||
| 370 | PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY | ||
| 371 | YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR | ||
| 372 | CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR | ||
| 373 | CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, | ||
| 374 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 375 | |||
| 376 | =cut | ||
| 377 | |||
| 378 | package StreamFinder::Blogger; | ||
| 379 | |||
| 380 | use strict; | ||
| 381 | use warnings; | ||
| 382 | use URI::Escape; | ||
| 383 | use HTML::Entities (); | ||
| 384 | use LWP::UserAgent (); | ||
| 385 | use parent 'StreamFinder::_Class'; | ||
| 386 | |||
| 387 | my $DEBUG = 0; | ||
| 388 | |||
| 389 | sub new | ||
| 390 | { | ||
| 391 | my $class = shift; | ||
| 392 | my $url = shift; | ||
| 393 | |||
| 394 | return undef unless ($url); | ||
| 395 | |||
| 396 | my $self = $class->SUPER::new('Blogger', @_); | ||
| 397 | $DEBUG = $self->{'debug'} if (defined $self->{'debug'}); | ||
| 398 | |||
| 399 | $self->{'youtube'} = 'no'; | ||
| 400 | while (@_) { | ||
| 401 | if ($_[0] =~ /^\-?youtube$/o) { | ||
| 402 | shift; | ||
| 403 | $self->{'youtube'} = (defined $_[0]) ? shift : 'yes'; | ||
| 404 | } else { | ||
| 405 | shift; | ||
| 406 | } | ||
| 407 | } | ||
| 408 | |||
| 409 | print STDERR "-0(Blogger): URL=$url=\n" if ($DEBUG); | ||
| 410 | $url =~ s/\?autoplay\=true$//; #STRIP THIS OFF SO WE DON'T HAVE TO. | ||
| 411 | (my $url2fetch = $url); | ||
| 412 | print STDERR "-1 FETCHING URL=$url2fetch=\n" if ($DEBUG); | ||
| 413 | $self->{'title'} = 'untitled Blogger.com video'; | ||
| 414 | |||
| 415 | #FIRST TRY SCANNING MANUALLY!: | ||
| 416 | |||
| 417 | my $html = ''; | ||
| 418 | my $ua = LWP::UserAgent->new(@{$self->{'_userAgentOps'}}); | ||
| 419 | $ua->timeout($self->{'timeout'}); | ||
| 420 | $ua->cookie_jar({}); | ||
| 421 | $ua->env_proxy; | ||
| 422 | my $response = $ua->get($url2fetch); | ||
| 423 | if ($response->is_success) { | ||
| 424 | $html = $response->decoded_content; | ||
| 425 | } else { | ||
| 426 | print STDERR $response->status_line if ($DEBUG); | ||
| 427 | my $no_wget = system('wget','-V'); | ||
| 428 | unless ($no_wget) { | ||
| 429 | print STDERR "\n..trying wget...\n" if ($DEBUG); | ||
| 430 | $html = `wget -t 2 -T 20 -O- -o /dev/null "$url2fetch" 2>/dev/null `; | ||
| 431 | } | ||
| 432 | } | ||
| 433 | |||
| 434 | =head2 testonly | ||
| 435 | |||
| 436 | $html = <<'ENDHTML'; | ||
| 437 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html dir="ltr"><head><style type="text/css"> | ||
| 438 | body, | ||
| 439 | .main, | ||
| 440 | #videocontainer, | ||
| 441 | .thumbnail-holder, | ||
| 442 | .play-button { | ||
| 443 | background: black; | ||
| 444 | height: 100vh; | ||
| 445 | margin: 0; | ||
| 446 | overflow: hidden; | ||
| 447 | position: absolute; | ||
| 448 | width: 100%; | ||
| 449 | } | ||
| 450 | |||
| 451 | #videocontainer.type-BLOGGER_UPLOADED .thumbnail-holder { | ||
| 452 | background-size: contain; | ||
| 453 | } | ||
| 454 | |||
| 455 | .thumbnail-holder { | ||
| 456 | background-repeat: no-repeat; | ||
| 457 | background-position: center; | ||
| 458 | z-index: 10; | ||
| 459 | } | ||
| 460 | |||
| 461 | .play-button { | ||
| 462 | background: url('https://www.gstatic.com/images/icons/material/system/1x/play_arrow_white_48dp.png') rgba(0,0,0,0.1) no-repeat center; | ||
| 463 | cursor: pointer; | ||
| 464 | display: block; | ||
| 465 | z-index: 20; | ||
| 466 | } | ||
| 467 | </style> | ||
| 468 | <script type="text/javascript"> | ||
| 469 | var VIDEO_CONFIG = {"thumbnail":"https://video.google.com/ThumbnailServer2?app\u003dblogger\u0026contentid\u003d4b85c0c7c4fa62c4\u0026offsetms\u003d5000\u0026itag\u003dw320\u0026expire\u003d1595683627\u0026sigh\u003d8KiGsQ9ENNk9ar92EdGBb7yw1fU","iframe_id":"BLOGGER-video-4b85c0c7c4fa62c4-3612","allow_resize":false,"streams":[{"play_url":"https://r4---sn-q4flrn7y.googlevideo.com/videoplayback?expire\u003d1595687227\u0026ei\u003du9AbX_j9I9qQrvIP8JCYuAc\u0026ip\u003d74.113.246.161\u0026id\u003d4b85c0c7c4fa62c4\u0026itag\u003d18\u0026source\u003dblogger\u0026mh\u003daH\u0026mm\u003d31\u0026mn\u003dsn-q4flrn7y\u0026ms\u003dau\u0026mv\u003dm\u0026mvi\u003d4\u0026pl\u003d24\u0026susc\u003dbl\u0026mime\u003dvideo/mp4\u0026dur\u003d54.172\u0026lmt\u003d1348112508420630\u0026mt\u003d1595658219\u0026sparams\u003dexpire,ei,ip,id,itag,source,susc,mime,dur,lmt\u0026sig\u003dAOq0QJ8wRQIhAPDDa3kNcLOfoVXp2Pn0rtl1g6Th9WNZpaKedGNyY_yxAiBRuA4ArLK4PozoFOl7E__WmFK0k5FJCysw8rFI7tCmfQ%3D%3D\u0026lsparams\u003dmh,mm,mn,ms,mv,mvi,pl\u0026lsig\u003dAG3C_xAwRgIhAO3j3Xm7z2fjkCG8JBeOH8B2-xT7aUvvJfAOohzWlaraAiEAy7k8NZZ1PIitjM8rM5DHqoK2l0hNsC6Pug91Yn7ZAbM%3D","format_id":18}]} | ||
| 470 | </script></head> | ||
| 471 | <body><div class="main"><div id="videocontainer" class="type-BLOGGER_UPLOADED"><div class="thumbnail-holder"></div> | ||
| 472 | <div class="play-button"></div></div></div> | ||
| 473 | <script type="text/javascript" src="https://www.blogger.com/static/v1/jsbin/764818548-video_compiled.js"></script> | ||
| 474 | ENDHTML | ||
| 475 | |||
| 476 | =cut | ||
| 477 | |||
| 478 | |||
| 479 | if ($html =~ s/^.+VIDEO_CONFIG\s*\=\s*\{//s) { | ||
| 480 | #$html =~ s/(?:\%|\\?u?00)([0-9A-Fa-f]{2})/chr(hex($1))/egs; | ||
| 481 | $html =~ s/\\u00([0-9A-Fa-f]{2})/chr(hex($1))/egs; | ||
| 482 | print "--HTML shortened to ===$html===\n" if ($DEBUG > 1); | ||
| 483 | $self->{'iconurl'} = ($html =~ m#\"thumbnail\"\:\"([^\"]+)#) ? $1 : ''; | ||
| 484 | $self->{'id'} = ($html =~ m#\"iframe\_id\"\:\"([^\"]+)#) ? $1 : ''; | ||
| 485 | if ($html =~ /\"streams\"\:\[([^\]]+)\]/s) { | ||
| 486 | $html = $1; | ||
| 487 | while ($html =~ s/\{\"play\_url\"\:\"([^\"]+)\"//s) { | ||
| 488 | my $one = $1; | ||
| 489 | unless ($self->{'secure'} && $one !~ /^https/o) { | ||
| 490 | push @{$self->{'streams'}}, $one; | ||
| 491 | $self->{'cnt'}++; | ||
| 492 | } | ||
| 493 | } | ||
| 494 | $self->{'imageurl'} = $self->{'iconurl'}; | ||
| 495 | $self->{'total'} = $self->{'cnt'}; | ||
| 496 | if ($self->{'total'} > 0) { | ||
| 497 | print STDERR "\n--SUCCESS2: CNT=".$self->{'total'}."= ID=".$self->{'id'}."=\n--TITLE=".$self->{'title'}."\n--STREAMS=".join('|',@{$self->{'streams'}})."=\n" if ($DEBUG); | ||
| 498 | $self->_log($url); | ||
| 499 | |||
| 500 | bless $self, $class; #BLESS IT! | ||
| 501 | |||
| 502 | return $self; | ||
| 503 | } | ||
| 504 | } | ||
| 505 | |||
| 506 | } else { | ||
| 507 | print "--html in===$html===\n"; | ||
| 508 | } | ||
| 509 | |||
| 510 | if ($self->{'cnt'} <= 0 || $self->{'youtube'} =~ /(?:yes|top|first|last)/i) { | ||
| 511 | my $haveYoutube = 0; | ||
| 512 | eval { require 'StreamFinder/Youtube.pm'; $haveYoutube = 1; }; | ||
| 513 | print STDERR "\n-2 NO STREAMS FOUND IN PAGE (haveYoutube=$haveYoutube)\n" if ($DEBUG && $self->{'cnt'} <= 0); | ||
| 514 | if ($haveYoutube) { | ||
| 515 | print STDERR "\n-2 TRYING youtube-dl($self->{'youtube'})...\n" if ($DEBUG && $self->{'youtube'} =~ /(?:yes|top|first)/i); | ||
| 516 | my %globalArgs = ( | ||
| 517 | '-noiframes' => 1, '-fast' => 1, '-debug' => $DEBUG | ||
| 518 | ); | ||
| 519 | foreach my $arg (qw(secure log logfmt youtube-format youtube-format-fallback | ||
| 520 | youtube-formatonly youtube-dl-args youtube-dl-add-args)) { | ||
| 521 | (my $arg0 = $arg) =~ s/^youtube\-(?!dl)//o; | ||
| 522 | $globalArgs{$arg0} = $self->{$arg} if (defined $self->{$arg}); | ||
| 523 | } | ||
| 524 | my $yt = new StreamFinder::Youtube($url2fetch, %globalArgs); | ||
| 525 | if ($yt && $yt->count() > 0) { | ||
| 526 | my @ytStreams = $yt->get(); | ||
| 527 | if ($self->{'youtube'} =~ /(?:top|first)/i) { #PUT youtube-dl STREAMS ON TOP: | ||
| 528 | unshift @{$self->{'streams'}}, @ytStreams; | ||
| 529 | } else { | ||
| 530 | push @{$self->{'streams'}}, @ytStreams; | ||
| 531 | } | ||
| 532 | foreach my $field (qw(title description)) { | ||
| 533 | $self->{$field} ||= $yt->{$field} if (defined($yt->{$field}) && $yt->{$field}); | ||
| 534 | } | ||
| 535 | $self->{'cnt'} = scalar @{$self->{'streams'}}; | ||
| 536 | print STDERR "i:Found stream(s) (".join('|',@ytStreams).") via youtube-dl.\n" if ($DEBUG); | ||
| 537 | } | ||
| 538 | } | ||
| 539 | print STDERR "-count=".$self->{'cnt'}."= iconurl=".$self->{'iconurl'}."=\n" if ($DEBUG); | ||
| 540 | } | ||
| 541 | if ($self->{'description'} =~ /\w/) { | ||
| 542 | $self->{'description'} =~ s/\s+$//; | ||
| 543 | } else { | ||
| 544 | $self->{'description'} = $self->{'title'}; | ||
| 545 | } | ||
| 546 | $self->{'description'} = HTML::Entities::decode_entities($self->{'description'}); | ||
| 547 | $self->{'description'} = uri_unescape($self->{'description'}); | ||
| 548 | $self->{'title'} = HTML::Entities::decode_entities($self->{'title'}); | ||
| 549 | $self->{'title'} = uri_unescape($self->{'title'}); | ||
| 550 | $self->{'imageurl'} = $self->{'iconurl'}; | ||
| 551 | $self->{'total'} = $self->{'cnt'}; | ||
| 552 | $self->{'Url'} = ($self->{'total'} > 0) ? $self->{'streams'}->[0] : ''; | ||
| 553 | print STDERR "--SUCCESS: 1st stream=".$self->{'Url'}."= total=".$self->{'total'}."=\n" | ||
| 554 | if ($DEBUG && $self->{'cnt'} > 0); | ||
| 555 | print STDERR "\n--ID=".$self->{'id'}."=\n--TITLE=".$self->{'title'}."=\n--CNT=".$self->{'cnt'}."=\n--ICON=".$self->{'iconurl'}."=\n--1ST=".$self->{'Url'}."=\n--streams=".join('|',@{$self->{'streams'}})."=\n" if ($DEBUG); | ||
| 556 | $self->_log($url); | ||
| 557 | |||
| 558 | bless $self, $class; #BLESS IT! | ||
| 559 | |||
| 560 | return $self; | ||
| 561 | } | ||
| 562 | |||
| 563 | sub getImageData | ||
| 564 | { | ||
| 565 | my $self = shift; | ||
| 566 | return $self->getIconData(); | ||
| 567 | } | ||
| 568 | |||
| 569 | 1 |