Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update YoutubeExplode to the latest version (6.4.3+) #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
# Денацифицированный YoutubeDownloader (RU)
**YoutubeDownloaderRU** основан на данном репозитории: https://github.com/Tyrrrz/YoutubeDownloader
# YoutubeDownloader (RU)

<p align="center">
<img src="favicon.png" alt="Icon" />
</p>

# Как скачать
Последняя версия: v2.38
<br />Дата: 13.01.2024
<br />Ссылка в **Releases** : [Нажмите, чтобы скачать](https://github.com/reawoken/YoutubeDownloaderRU/releases/download/v2.38/YoutubeDownloaderRU.v2.38.zip)
Based on: https://github.com/Tyrrrz/YoutubeDownloader

# Почему я сделал YoutubeDownloaderRU
Чтобы каждый мог им пользоваться, независимо от идеологии и местопложения. Автор данного приложения закоренелый нацист и русособ, который распространяет недопустимую пропаганду в приложении, вообще не имеющем отношения к политике, войнам и прочему.
**YoutubeDownloader** is an application that lets you download videos from YouTube.
You can copy-paste URL of any video, playlist or channel and download it directly to a format of your choice.
It also supports searching by keywords, which is helpful if you want to quickly look up and download videos.

# Что было изменено
Основано на версии оригинального репозитория 12.01.2024
- Полностью удалена проверка национальной принадлежности по локали системы, которая запрещала запуск приложения в России и Белоруссии. Приложение может запустить **кто угодно и где угодно**, будь то житель России, Украины, Белоруссии и любой другой страны.
- Больше не опирается на внешние библиотеки автора через NuGet, теперь они часть проекта в репозитории. Также удалена зависимость от омерзительной библиотеки автора с омерзительным названием **deorcify**, которая не делает ничего, кроме дискриминации по национальному признаку.
- Вычищена подчистую вся политическая повестка (кроме скромной сноски в настройках), удалена вся агрессивная пропаганда и русофобия.
- Интерфейс полностью переведён на русский
- Убраны все упоминания авторства безумного пропагандиста, который изначально делал это приложение.
- Отключены обновления (возможно временно, в будущем смогу добавить свою систему обновлений, не опираясь на изначальный модуль если буду вообще обновлять этот репозиторий)
**YoutubeDownloader (RU)** features complete country restrictions bypass.

# Как собрать
Просто скачать и открыть **YoutubeDownloader.sln** в Visual Studio 2022 последней версии с установленным .NET 8.0 и собрать.
<br />Собранный проект появится в директории **YoutubeDownloaderRU\bin**.
> **Note**:
> **YoutubeDownloader** comes bundled with [FFmpeg](https://ffmpeg.org) which is used for processing videos.

## Features

- Cross-platform graphical user interface
- Download videos by URL
- Download videos from playlists or channels
- Download videos by search query
- Selectable video quality and format
- Automatically embed subtitles
- Automatically inject media tags
- Log in with a YouTube account to access private content
15 changes: 7 additions & 8 deletions YoutubeExplode/YoutubeExplode/Bridge/DashManifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ internal partial class DashManifest(XElement content)
content
.Descendants("Representation")
.Where(x => x.Attribute("id")?.Value.All(char.IsDigit) == true)
.Where(
x =>
x.Descendants("Initialization")
.FirstOrDefault()
?.Attribute("sourceURL")
?.Value
.Contains("sq/") != true
.Where(x =>
x.Descendants("Initialization")
.FirstOrDefault()
?.Attribute("sourceURL")
?.Value.Contains("sq/") != true
)
// Skip streams without codecs
.Where(x => !string.IsNullOrWhiteSpace(x.Attribute("codecs")?.Value))
Expand Down Expand Up @@ -58,7 +56,8 @@ public class StreamData(XElement content) : IStreamData

[Lazy]
public string? Container =>
Url?.Pipe(s => Regex.Match(s, @"mime[/=]\w*%2F([\w\d]*)").Groups[1].Value)
Url
?.Pipe(s => Regex.Match(s, @"mime[/=]\w*%2F([\w\d]*)").Groups[1].Value)
.Pipe(WebUtility.UrlDecode);

[Lazy]
Expand Down
2 changes: 2 additions & 0 deletions YoutubeExplode/YoutubeExplode/Bridge/IPlaylistData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ internal interface IPlaylistData

string? Description { get; }

int? Count { get; }

IReadOnlyList<ThumbnailData> Thumbnails { get; }
}
40 changes: 38 additions & 2 deletions YoutubeExplode/YoutubeExplode/Bridge/PlaylistBrowseResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,14 @@ internal partial class PlaylistBrowseResponse(JsonElement content) : IPlaylistDa
?.EnumerateArrayOrNull()
?.Select(j => j.GetPropertyOrNull("text")?.GetStringOrNull())
.WhereNotNull()
.ConcatToString();
.ConcatToString()
?? SidebarPrimary
?.GetPropertyOrNull("titleForm")
?.GetPropertyOrNull("inlineFormRenderer")
?.GetPropertyOrNull("formField")
?.GetPropertyOrNull("textInputFormFieldRenderer")
?.GetPropertyOrNull("value")
?.GetStringOrNull();

[Lazy]
private JsonElement? AuthorDetails =>
Expand Down Expand Up @@ -86,7 +93,36 @@ internal partial class PlaylistBrowseResponse(JsonElement content) : IPlaylistDa
?.EnumerateArrayOrNull()
?.Select(j => j.GetPropertyOrNull("text")?.GetStringOrNull())
.WhereNotNull()
.ConcatToString();
.ConcatToString()
?? SidebarPrimary
?.GetPropertyOrNull("descriptionForm")
?.GetPropertyOrNull("inlineFormRenderer")
?.GetPropertyOrNull("formField")
?.GetPropertyOrNull("textInputFormFieldRenderer")
?.GetPropertyOrNull("value")
?.GetStringOrNull();

[Lazy]
public int? Count =>
SidebarPrimary
?.GetPropertyOrNull("stats")
?.EnumerateArrayOrNull()
?.FirstOrNull()
?.GetPropertyOrNull("runs")
?.EnumerateArrayOrNull()
?.FirstOrNull()
?.GetPropertyOrNull("text")
?.GetStringOrNull()
?.ParseIntOrNull()
?? SidebarPrimary
?.GetPropertyOrNull("stats")
?.EnumerateArrayOrNull()
?.FirstOrNull()
?.GetPropertyOrNull("simpleText")
?.GetStringOrNull()
?.Split(' ')
?.FirstOrDefault()
?.ParseIntOrNull();

[Lazy]
public IReadOnlyList<ThumbnailData> Thumbnails =>
Expand Down
22 changes: 20 additions & 2 deletions YoutubeExplode/YoutubeExplode/Bridge/PlaylistNextResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,26 @@ internal partial class PlaylistNextResponse(JsonElement content) : IPlaylistData
public string? Description => null;

[Lazy]
public IReadOnlyList<ThumbnailData> Thumbnails =>
Videos.FirstOrDefault()?.Thumbnails ?? Array.Empty<ThumbnailData>();
public int? Count =>
ContentRoot
?.GetPropertyOrNull("totalVideosText")
?.GetPropertyOrNull("runs")
?.EnumerateArrayOrNull()
?.FirstOrNull()
?.GetPropertyOrNull("text")
?.GetStringOrNull()
?.ParseIntOrNull()
?? ContentRoot
?.GetPropertyOrNull("videoCountText")
?.GetPropertyOrNull("runs")
?.EnumerateArrayOrNull()
?.ElementAtOrNull(2)
?.GetPropertyOrNull("text")
?.GetStringOrNull()
?.ParseIntOrNull();

[Lazy]
public IReadOnlyList<ThumbnailData> Thumbnails => Videos.FirstOrDefault()?.Thumbnails ?? [];

[Lazy]
public IReadOnlyList<PlaylistVideoData> Videos =>
Expand Down
7 changes: 7 additions & 0 deletions YoutubeExplode/YoutubeExplode/Bridge/SearchResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ internal class VideoData(JsonElement content)
[Lazy]
public string? ChannelId =>
AuthorDetails
?.GetPropertyOrNull("navigationEndpoint")
?.GetPropertyOrNull("browseEndpoint")
?.GetPropertyOrNull("browseId")
?.GetStringOrNull()
?? content
.GetPropertyOrNull("channelThumbnailSupportedRenderers")
?.GetPropertyOrNull("channelThumbnailWithLinkRenderer")
?.GetPropertyOrNull("navigationEndpoint")
?.GetPropertyOrNull("browseEndpoint")
?.GetPropertyOrNull("browseId")
Expand Down
67 changes: 32 additions & 35 deletions YoutubeExplode/YoutubeExplode/Bridge/VideoWatchPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,33 +31,31 @@ internal partial class VideoWatchPage(IHtmlDocument content)
[Lazy]
public long? LikeCount =>
content
.Source.Text.Pipe(
s =>
Regex
.Match(
s,
"""
"\s*:\s*"([\d,\.]+) likes"
"""
)
.Groups[1]
.Value
.Source.Text.Pipe(s =>
Regex
.Match(
s,
"""
"\s*:\s*"([\d,\.]+) likes"
"""
)
.Groups[1]
.Value
)
.NullIfWhiteSpace()
?.StripNonDigit()
.ParseLongOrNull()
?? content
.Source.Text.Pipe(
s =>
Regex
.Match(
s,
"""
along with ([\d,\.]+) other people"
"""
)
.Groups[1]
.Value
.Source.Text.Pipe(s =>
Regex
.Match(
s,
"""
along with ([\d,\.]+) other people"
"""
)
.Groups[1]
.Value
)
.NullIfWhiteSpace()
?.StripNonDigit()
Expand All @@ -66,17 +64,16 @@ along with ([\d,\.]+) other people"
[Lazy]
public long? DislikeCount =>
content
.Source.Text.Pipe(
s =>
Regex
.Match(
s,
"""
"\s*:\s*"([\d,\.]+) dislikes"
"""
)
.Groups[1]
.Value
.Source.Text.Pipe(s =>
Regex
.Match(
s,
"""
"\s*:\s*"([\d,\.]+) dislikes"
"""
)
.Groups[1]
.Value
)
.NullIfWhiteSpace()
?.StripNonDigit()
Expand All @@ -98,8 +95,8 @@ along with ([\d,\.]+) other people"
content
.GetElementsByTagName("script")
.Select(e => e.Text())
.Select(
s => Regex.Match(s, @"var\s+ytInitialPlayerResponse\s*=\s*(\{.*\})").Groups[1].Value
.Select(s =>
Regex.Match(s, @"var\s+ytInitialPlayerResponse\s*=\s*(\{.*\})").Groups[1].Value
)
.FirstOrDefault(s => !string.IsNullOrWhiteSpace(s))
?.NullIfWhiteSpace()
Expand Down
2 changes: 1 addition & 1 deletion YoutubeExplode/YoutubeExplode/Channels/ChannelClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public async ValueTask<Channel> GetAsync(
new Thumbnail(
"https://www.gstatic.com/youtube/img/tvfilm/clapperboard_profile.png",
new Resolution(1024, 1024)
)
),
]
);
}
Expand Down
2 changes: 1 addition & 1 deletion YoutubeExplode/YoutubeExplode/Common/Thumbnail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ internal static IReadOnlyList<Thumbnail> GetDefaultSet(VideoId videoId) =>
new Thumbnail(
$"https://img.youtube.com/vi/{videoId}/hqdefault.jpg",
new Resolution(480, 360)
)
),
];
}

Expand Down
9 changes: 9 additions & 0 deletions YoutubeExplode/YoutubeExplode/Playlists/Playlist.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class Playlist(
string title,
Author? author,
string description,
int? count,
IReadOnlyList<Thumbnail> thumbnails
) : IPlaylist
{
Expand All @@ -32,6 +33,14 @@ IReadOnlyList<Thumbnail> thumbnails
/// </summary>
public string Description { get; } = description;

/// <summary>
/// Total count of videos included in the playlist.
/// </summary>
/// <remarks>
/// May be null in case of infinite playlists (e.g. auto-generated mixes).
/// </remarks>
public int? Count { get; } = count;

/// <inheritdoc />
public IReadOnlyList<Thumbnail> Thumbnails { get; } = thumbnails;

Expand Down
4 changes: 3 additions & 1 deletion YoutubeExplode/YoutubeExplode/Playlists/PlaylistClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ channelId is not null && channelTitle is not null
// System playlists have no description
var description = response.Description ?? "";

var count = response.Count;

var thumbnails = response
.Thumbnails.Select(t =>
{
Expand All @@ -63,7 +65,7 @@ channelId is not null && channelTitle is not null
})
.ToArray();

return new Playlist(playlistId, title, author, description, thumbnails);
return new Playlist(playlistId, title, author, description, count, thumbnails);
}

/// <summary>
Expand Down
Loading