diff --git a/README.md b/README.md index ee9d117..67af2b3 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ import 'package:youtube_explode_dart/youtube_explode_dart.dart'; ```dart // You can provide either a video ID or URL as String or an instance of `VideoId`. -var video = yt.videos.get('https://youtube.com/watch?v=Dpp1sIL1m5Q'); // Returns a Video instance. +var video = yt.videos.get('http://127.0.0.1:8080/youtube.com:443/watch?v=Dpp1sIL1m5Q'); // Returns a Video instance. var title = video.title; // "Scamazon Prime" var author = video.author; // "Jim Browning" diff --git a/lib/src/channels/channel.dart b/lib/src/channels/channel.dart index a47edfc..9699e19 100644 --- a/lib/src/channels/channel.dart +++ b/lib/src/channels/channel.dart @@ -26,7 +26,7 @@ class Channel with _$Channel { ) = _Channel; /// Channel URL. - String get url => 'https://www.youtube.com/channel/$id'; + String get url => 'http://127.0.0.1:8080/www.youtube.com:443/channel/$id'; const Channel._(); } diff --git a/lib/src/playlists/playlist.dart b/lib/src/playlists/playlist.dart index d708fb8..1d4d385 100644 --- a/lib/src/playlists/playlist.dart +++ b/lib/src/playlists/playlist.dart @@ -37,5 +37,6 @@ class Playlist with _$Playlist { const Playlist._(); /// Playlist URL. - String get url => 'https://www.youtube.com/playlist?list=$id'; + String get url => + 'http://127.0.0.1:8080/www.youtube.com:443/playlist?list=$id'; } diff --git a/lib/src/reverse_engineering/clients/embedded_player_client.dart b/lib/src/reverse_engineering/clients/embedded_player_client.dart index c6d8644..cd010d2 100644 --- a/lib/src/reverse_engineering/clients/embedded_player_client.dart +++ b/lib/src/reverse_engineering/clients/embedded_player_client.dart @@ -58,7 +58,8 @@ class EmbeddedPlayerClient { 'videoId': videoId }; - final url = Uri.parse('https://www.youtube.com/youtubei/v1/player'); + final url = Uri.parse( + 'http://127.0.0.1:8080/www.youtube.com:443/youtubei/v1/player'); return retry(httpClient, () async { final raw = await httpClient.post(url, diff --git a/lib/src/reverse_engineering/pages/channel_about_page.dart b/lib/src/reverse_engineering/pages/channel_about_page.dart index 57f2023..8479e1d 100644 --- a/lib/src/reverse_engineering/pages/channel_about_page.dart +++ b/lib/src/reverse_engineering/pages/channel_about_page.dart @@ -36,7 +36,8 @@ class ChannelAboutPage extends YoutubePage<_InitialData> { /// static Future get(YoutubeHttpClient httpClient, String id) { - var url = 'https://www.youtube.com/channel/$id/about?hl=en'; + var url = + 'http://127.0.0.1:8080/www.youtube.com:443/channel/$id/about?hl=en'; return retry(httpClient, () async { var raw = await httpClient.getString(url); @@ -49,7 +50,8 @@ class ChannelAboutPage extends YoutubePage<_InitialData> { /// static Future getByUsername( YoutubeHttpClient httpClient, String username) { - var url = 'https://www.youtube.com/user/$username/about?hl=en'; + var url = + 'http://127.0.0.1:8080/www.youtube.com:443/user/$username/about?hl=en'; return retry(httpClient, () async { var raw = await httpClient.getString(url); diff --git a/lib/src/reverse_engineering/pages/channel_page.dart b/lib/src/reverse_engineering/pages/channel_page.dart index 892b2b9..03fcc32 100644 --- a/lib/src/reverse_engineering/pages/channel_page.dart +++ b/lib/src/reverse_engineering/pages/channel_page.dart @@ -40,7 +40,7 @@ class ChannelPage extends YoutubePage<_InitialData> { /// static Future get(YoutubeHttpClient httpClient, String id) { - var url = 'https://www.youtube.com/channel/$id?hl=en'; + var url = 'http://127.0.0.1:8080/www.youtube.com:443/channel/$id?hl=en'; return retry(httpClient, () async { var raw = await httpClient.getString(url); @@ -56,7 +56,7 @@ class ChannelPage extends YoutubePage<_InitialData> { /// static Future getByUsername( YoutubeHttpClient httpClient, String username) { - var url = 'https://www.youtube.com/user/$username?hl=en'; + var url = 'http://127.0.0.1:8080/www.youtube.com:443/user/$username?hl=en'; return retry(httpClient, () async { try { @@ -71,7 +71,7 @@ class ChannelPage extends YoutubePage<_InitialData> { if (e.statusCode != 404) { rethrow; } - url = 'https://www.youtube.com/c/$username?hl=en'; + url = 'http://127.0.0.1:8080/www.youtube.com:443/c/$username?hl=en'; } throw FatalFailureException('', 0); }); diff --git a/lib/src/reverse_engineering/pages/channel_upload_page.dart b/lib/src/reverse_engineering/pages/channel_upload_page.dart index a67b274..110c151 100644 --- a/lib/src/reverse_engineering/pages/channel_upload_page.dart +++ b/lib/src/reverse_engineering/pages/channel_upload_page.dart @@ -35,7 +35,7 @@ class ChannelUploadPage extends YoutubePage<_InitialData> { static Future get( YoutubeHttpClient httpClient, String channelId, String sorting) { var url = - 'https://www.youtube.com/channel/$channelId/videos?view=0&sort=$sorting&flow=grid'; + 'http://127.0.0.1:8080/www.youtube.com:443/channel/$channelId/videos?view=0&sort=$sorting&flow=grid'; return retry(httpClient, () async { var raw = await httpClient.getString(url); return ChannelUploadPage.parse(raw, channelId); diff --git a/lib/src/reverse_engineering/pages/embed_page.dart b/lib/src/reverse_engineering/pages/embed_page.dart index 0699ba1..d883972 100644 --- a/lib/src/reverse_engineering/pages/embed_page.dart +++ b/lib/src/reverse_engineering/pages/embed_page.dart @@ -29,7 +29,7 @@ class EmbedPage { if (url == null) { return null; } - return 'https://youtube.com$url'; + return 'http://127.0.0.1:8080/youtube.com:443$url'; } /// @@ -69,7 +69,7 @@ class EmbedPage { /// static Future get(YoutubeHttpClient httpClient, String videoId) { - var url = 'https://youtube.com/embed/$videoId?hl=en'; + var url = 'http://127.0.0.1:8080/youtube.com:443/embed/$videoId?hl=en'; // final url = 'http://localhost:8080/embed/$videoId?hl=en'; return retry(httpClient, () async { var raw = await httpClient.getString(url); @@ -87,5 +87,6 @@ class EmbedPlayerConfig implements PlayerConfigBase { EmbedPlayerConfig(this.root); @override - String get sourceUrl => 'https://youtube.com${root['assets']['js']}'; + String get sourceUrl => + 'http://127.0.0.1:8080/youtube.com:443${root['assets']['js']}'; } diff --git a/lib/src/reverse_engineering/pages/playlist_page.dart b/lib/src/reverse_engineering/pages/playlist_page.dart index 141e4d5..65742a3 100644 --- a/lib/src/reverse_engineering/pages/playlist_page.dart +++ b/lib/src/reverse_engineering/pages/playlist_page.dart @@ -46,7 +46,8 @@ class PlaylistPage extends YoutubePage<_InitialData> { YoutubeHttpClient httpClient, String id, ) async { - var url = 'https://www.youtube.com/playlist?list=$id&hl=en&persist_hl=1'; + var url = + 'http://127.0.0.1:8080/www.youtube.com:443/playlist?list=$id&hl=en&persist_hl=1'; return retry(httpClient, () async { var raw = await httpClient.getString(url); return PlaylistPage.parse(raw, id); diff --git a/lib/src/reverse_engineering/pages/search_page.dart b/lib/src/reverse_engineering/pages/search_page.dart index 0125755..01a75f7 100644 --- a/lib/src/reverse_engineering/pages/search_page.dart +++ b/lib/src/reverse_engineering/pages/search_page.dart @@ -39,7 +39,7 @@ class SearchPage extends YoutubePage<_InitialData> { YoutubeHttpClient httpClient, String queryString, {SearchFilter filter = const SearchFilter('')}) { var url = - 'https://www.youtube.com/results?search_query=${Uri.encodeQueryComponent(queryString)}&sp=${filter.value}'; + 'http://127.0.0.1:8080/www.youtube.com:443/results?search_query=${Uri.encodeQueryComponent(queryString)}&sp=${filter.value}'; return retry(httpClient, () async { var raw = await httpClient.getString(url); return SearchPage.parse(raw, queryString); diff --git a/lib/src/reverse_engineering/pages/watch_page.dart b/lib/src/reverse_engineering/pages/watch_page.dart index da8de2a..d9a9ef1 100644 --- a/lib/src/reverse_engineering/pages/watch_page.dart +++ b/lib/src/reverse_engineering/pages/watch_page.dart @@ -41,7 +41,7 @@ class WatchPage extends YoutubePage<_InitialData> { if (url == null) { return null; } - return 'https://youtube.com$url'; + return 'http://127.0.0.1:8080/youtube.com:443$url'; } /// @@ -120,7 +120,8 @@ class WatchPage extends YoutubePage<_InitialData> { /// static Future get(YoutubeHttpClient httpClient, String videoId) { - final url = 'https://youtube.com/watch?v=$videoId&bpctr=9999999999&hl=en'; + final url = + 'http://127.0.0.1:8080/youtube.com:443/watch?v=$videoId&bpctr=9999999999&hl=en'; return retry(httpClient, () async { var req = await httpClient.get(url, validate: true); @@ -151,7 +152,7 @@ class WatchPlayerConfig implements PlayerConfigBase { @override late final String sourceUrl = - 'https://youtube.com${root.get('assets')!.getT('js')}'; + 'http://127.0.0.1:8080/youtube.com:443${root.get('assets')!.getT('js')}'; /// late final PlayerResponse playerResponse = diff --git a/lib/src/reverse_engineering/youtube_http_client.dart b/lib/src/reverse_engineering/youtube_http_client.dart index 8b57169..7880f71 100644 --- a/lib/src/reverse_engineering/youtube_http_client.dart +++ b/lib/src/reverse_engineering/youtube_http_client.dart @@ -231,7 +231,7 @@ class YoutubeHttpClient extends http.BaseClient { }; final url = Uri.parse( - 'https://www.youtube.com/youtubei/v1/$action?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8'); + 'http://127.0.0.1:8080/www.youtube.com:443/youtubei/v1/$action?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8'); return retry(this, () async { final raw = await post(url, body: json.encode(body)); diff --git a/lib/src/videos/video.dart b/lib/src/videos/video.dart index 4465c44..5cfecae 100644 --- a/lib/src/videos/video.dart +++ b/lib/src/videos/video.dart @@ -11,7 +11,7 @@ part 'video.freezed.dart'; @freezed class Video with _$Video { /// Video URL. - String get url => 'https://www.youtube.com/watch?v=$id'; + String get url => 'http://127.0.0.1:8080/www.youtube.com:443/watch?v=$id'; /// Returns true if the watch page is available for this video. bool get hasWatchPage => watchPage != null; diff --git a/lib/src/videos/video_id.dart b/lib/src/videos/video_id.dart index 041bfa7..2592448 100644 --- a/lib/src/videos/video_id.dart +++ b/lib/src/videos/video_id.dart @@ -67,7 +67,7 @@ class VideoId with _$VideoId { return url; } - // https://www.youtube.com/watch?v=yIVRs6YSbOM + // http://127.0.0.1:8080/www.youtube.com:443/watch?v=yIVRs6YSbOM var regMatch = _regMatchExp.firstMatch(url)?.group(1); if (!regMatch.isNullOrWhiteSpace && validateVideoId(regMatch!)) { return regMatch; @@ -79,13 +79,13 @@ class VideoId with _$VideoId { return shortMatch; } - // https://www.youtube.com/embed/yIVRs6YSbOM + // http://127.0.0.1:8080/www.youtube.com:443/embed/yIVRs6YSbOM var embedMatch = _embedMatchExp.firstMatch(url)?.group(1); if (!embedMatch.isNullOrWhiteSpace && validateVideoId(embedMatch!)) { return embedMatch; } - // https://www.youtube.com/shorts/yIVRs6YSbOM + // http://127.0.0.1:8080/www.youtube.com:443/shorts/yIVRs6YSbOM var shortsMatch = _shortsMatchExp.firstMatch(url)?.group(1); if (!shortsMatch.isNullOrWhiteSpace && validateVideoId(shortsMatch!)) { return shortsMatch; diff --git a/test/channel_about_test.dart b/test/channel_about_test.dart index 166564b..872a5df 100644 --- a/test/channel_about_test.dart +++ b/test/channel_about_test.dart @@ -12,7 +12,7 @@ void main() { }); test('Get a channel about page', () async { - var channelUrl = 'https://www.youtube.com/user/FavijTV'; + var channelUrl = 'http://127.0.0.1:8080/www.youtube.com:443/user/FavijTV'; var channel = await yt!.channels.getAboutPageByUsername(channelUrl); expect(channel.country, 'Italy'); expect(channel.thumbnails, isNotEmpty); diff --git a/test/channel_test.dart b/test/channel_test.dart index 85b805a..f0d95ef 100644 --- a/test/channel_test.dart +++ b/test/channel_test.dart @@ -12,7 +12,8 @@ void main() { }); test('Get metadata of a channel', () async { - var channelUrl = 'https://www.youtube.com/channel/UCEnBXANsKmyj2r9xVyKoDiQ'; + var channelUrl = + 'http://127.0.0.1:8080/www.youtube.com:443/channel/UCEnBXANsKmyj2r9xVyKoDiQ'; var channel = await yt!.channels.get(ChannelId(channelUrl)); expect(channel.url, channelUrl); expect(channel.title, 'Tyrrrz'); @@ -48,7 +49,7 @@ void main() { test('Get the videos of a youtube channel', () async { var videos = await yt!.channels .getUploads(ChannelId( - 'https://www.youtube.com/channel/UCEnBXANsKmyj2r9xVyKoDiQ')) + 'http://127.0.0.1:8080/www.youtube.com:443/channel/UCEnBXANsKmyj2r9xVyKoDiQ')) .toList(); expect(videos.length, greaterThanOrEqualTo(75)); }); diff --git a/test/comments_client_test.dart b/test/comments_client_test.dart index 84e1f72..f790a7b 100644 --- a/test/comments_client_test.dart +++ b/test/comments_client_test.dart @@ -12,7 +12,8 @@ void main() { }); test('Get comments of a video', () async { - var videoUrl = 'https://www.youtube.com/watch?v=AI7ULzgf8RU'; + var videoUrl = + 'http://127.0.0.1:8080/www.youtube.com:443/watch?v=AI7ULzgf8RU'; var video = await yt!.videos.get(VideoId(videoUrl)); var comments = (await yt!.videos.commentsClient.getComments(video))!; expect(comments.length, greaterThanOrEqualTo(1)); diff --git a/test/playlist_test.dart b/test/playlist_test.dart index ca93cfd..613bc34 100644 --- a/test/playlist_test.dart +++ b/test/playlist_test.dart @@ -13,7 +13,7 @@ void main() { test('Get metadata of a playlist', () async { var playlistUrl = - 'https://www.youtube.com/playlist?list=PLr-IftNTIujSF-8tlGbZBQyGIT6TCF6Yd'; + 'http://127.0.0.1:8080/www.youtube.com:443/playlist?list=PLr-IftNTIujSF-8tlGbZBQyGIT6TCF6Yd'; var playlist = await yt!.playlists.get(PlaylistId(playlistUrl)); expect(playlist.id.value, 'PLr-IftNTIujSF-8tlGbZBQyGIT6TCF6Yd'); expect(playlist.url, playlistUrl); @@ -48,7 +48,7 @@ void main() { test('Get more than 100 videos in a playlist', () async { var videos = await yt!.playlists .getVideos(PlaylistId( - 'https://www.youtube.com/playlist?list=PLCSusC_jlo14J0uBgFqfHsKu7gc5W2HyM')) + 'http://127.0.0.1:8080/www.youtube.com:443/playlist?list=PLCSusC_jlo14J0uBgFqfHsKu7gc5W2HyM')) .toList(); expect(videos.length, greaterThan(100)); }); diff --git a/test/video_test.dart b/test/video_test.dart index e1332ef..a7a1476 100644 --- a/test/video_test.dart +++ b/test/video_test.dart @@ -12,7 +12,8 @@ void main() { }); test('Get metadata of a video', () async { - var videoUrl = 'https://www.youtube.com/watch?v=AI7ULzgf8RU'; + var videoUrl = + 'http://127.0.0.1:8080/www.youtube.com:443/watch?v=AI7ULzgf8RU'; var video = await yt!.videos.get(VideoId(videoUrl)); expect(video.id.value, 'AI7ULzgf8RU'); expect(video.url, videoUrl);