New version 1.15.2
Fix extraction for same videos. This closes #76
(cherry picked from commit 0186ad3d7a
)
This commit is contained in:
parent
9fb4c6ac2a
commit
07651c3008
|
@ -3,6 +3,9 @@
|
|||
- Only throw custom exceptions from the library.
|
||||
- `getUploadsFromPage` no longer throws.
|
||||
|
||||
## 1.15.2
|
||||
- Fix extraction for same videos (#76)
|
||||
|
||||
## 1.5.1
|
||||
- BREAKING CHANGE: Renamed `getVideosAsync` to `getVideos`.
|
||||
- Implemented `getVideosFromPage` which supersedes `queryFromPage`.
|
||||
|
|
|
@ -11,6 +11,7 @@ import '../youtube_http_client.dart';
|
|||
class EmbedPage {
|
||||
static final _playerConfigExp =
|
||||
RegExp(r"'PLAYER_CONFIG':\s*(\{.*\})\}");
|
||||
|
||||
final Document _root;
|
||||
_PlayerConfig _playerConfig;
|
||||
String __playerConfigJson;
|
||||
|
|
|
@ -30,7 +30,7 @@ class PlayerSource {
|
|||
var val = RegExp(r'(?<=invalid namespace.*?;[\w\s]+=)\d+')
|
||||
.stringMatch(_root)
|
||||
?.nullIfWhitespace ??
|
||||
RegExp(r'(?<=this\.signatureTimestamp=)\d+"')
|
||||
RegExp(r'(?<=this\.signatureTimestamp=)\d+')
|
||||
.stringMatch(_root)
|
||||
?.nullIfWhitespace;
|
||||
if (val == null) {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:html/dom.dart';
|
||||
import 'package:html/parser.dart' as parser;
|
||||
|
||||
|
@ -84,18 +86,13 @@ class WatchPage {
|
|||
?.nullIfWhitespace ??
|
||||
'0');
|
||||
|
||||
static final _playerConfigExp = RegExp(r'ytplayer\.config\s*=\s*(\{.*\}\});');
|
||||
|
||||
///
|
||||
_PlayerConfig get playerConfig {
|
||||
if (_playerConfig != null) {
|
||||
return _playerConfig;
|
||||
}
|
||||
var text = _root.getElementsByTagName('html').first.text;
|
||||
if (!text.contains('ytplayer.config = ')) {
|
||||
return null;
|
||||
}
|
||||
return _playerConfig = _PlayerConfig(
|
||||
PlayerConfigJson.fromRawJson(_extractJson(text, 'ytplayer.config = ')));
|
||||
}
|
||||
_PlayerConfig get playerConfig =>
|
||||
_playerConfig ??= _PlayerConfig(json.decode(_playerConfigExp
|
||||
.firstMatch(_root.getElementsByTagName('html').first.text)
|
||||
?.group(1)));
|
||||
|
||||
String _extractJson(String html, String separator) {
|
||||
return _matchJson(
|
||||
|
|
|
@ -215,6 +215,7 @@ class StreamsClient {
|
|||
// We can try to extract the manifest from two sources:
|
||||
// get_video_info and the video watch page.
|
||||
// In some cases one works, in some cases another does.
|
||||
|
||||
try {
|
||||
var context = await _getStreamContextFromVideoInfo(videoId);
|
||||
return _getManifest(context);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name: youtube_explode_dart
|
||||
description: A port in dart of the youtube explode library. Supports several API functions without the need of Youtube API Key.
|
||||
version: 1.5.0
|
||||
version: 1.5.2
|
||||
homepage: https://github.com/Hexer10/youtube_explode_dart
|
||||
|
||||
environment:
|
||||
|
|
|
@ -14,7 +14,7 @@ void main() {
|
|||
|
||||
var data = {
|
||||
'9bZkp7q19f0',
|
||||
// 'SkRSXFQerZs', age restricted videos are not supported anymore.
|
||||
'SkRSXFQerZs',
|
||||
'hySoCSoH-g8',
|
||||
'_kmeFXjjGfk',
|
||||
'MeJVWBSsPAY',
|
||||
|
|
|
@ -25,7 +25,7 @@ void main() {
|
|||
expect(video.uploadDate.millisecondsSinceEpoch,
|
||||
inInclusiveRange(rangeMs - 86400000, rangeMs + 86400000));
|
||||
expect(video.description, contains('246pp'));
|
||||
expect(video.duration, const Duration(minutes: 1, seconds: 49));
|
||||
expect(video.duration, const Duration(minutes: 1, seconds: 48));
|
||||
expect(video.thumbnails.lowResUrl, isNotEmpty);
|
||||
expect(video.thumbnails.mediumResUrl, isNotEmpty);
|
||||
expect(video.thumbnails.highResUrl, isNotEmpty);
|
||||
|
|
Loading…
Reference in New Issue