Skip to content

Commit

Permalink
Merge branch 'Hexer10:master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
TijnvandenEijnde authored Aug 26, 2024
2 parents 24601ad + 699208f commit 1444068
Show file tree
Hide file tree
Showing 90 changed files with 1,713 additions and 819 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Publish to pub.dev

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*' # tag-pattern on pub.dev: 'v{{version}}'

# Publish using the reusable workflow from dart-lang.
jobs:
publish:
permissions:
id-token: write # Required for authentication using OIDC
uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
## 2.2.1
- Implement `VideoClient.get` to fetch a list of related videos given another Video.

## 2.2.0
- Implement shorts filter. Thanks to @igormidev #269.
- Implement `AudioTrack`s in `StreamInfo` to find the language of an audio track.
- Added `fullManifest` optional parameter for `StreamClient.getManifest` to fetch a manifest with more streams, including all the languages provided by YouTube.
- Fix issue where 1440p videos would be detected as 144p.
- Fix endless loop with fetching some playlists.

## 2.1.0
- BREAKING CHANGE:
- In `getUploadsFromPage`: the `videoSorting` parameter is now a named parameter
- Shorts filter possibility added in `getUploadsFromPage`.

## 2.0.4
- Fix issue when parsing dates formatted as "Streamed <q> <unit> ago" due to a leading whitespace. #265

## 2.0.3
- Better performance for iterating through closed captions elements. #251
- Add publishDate and viewCount for playlists. #240
- Fix fetching of YT music playlists. #261
- Fix like count extraction.

## 2.0.2
- Implement YT Handles.
- Deprecated ChannelLink icon's uri, they are no longer provided by YT.
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ var author = video.author; // "Jim Browning"
var duration = video.duration; // Instance of Duration - 0:19:48.00000
```

#### Get a list of related videos
```dart
var video = yt.videos.get('https://youtube.com/watch?v=Dpp1sIL1m5Q');
var relatedVideos = await yt.videos.getRelatedVideos(video); // video must be a Video instance.
print(relatedVideos); //prints the list of related videos
// to get the next page of related videos
relatedVideos = await relatedVideos.nextPage();
```

If no related video is found `getRelatedVideos` or `nextPage` will return null.

### Downloading a video stream
Every YouTube video has a number of streams available. These streams may have different containers, video quality, bitrate, etc.

Expand Down
2 changes: 1 addition & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include: package:lint/strict.yaml
include: package:lints/recommended.yaml

analyzer:
errors:
Expand Down
7 changes: 2 additions & 5 deletions example/video_download.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import 'dart:async';
import 'dart:io';

import 'package:console/console.dart';
import 'package:youtube_explode_dart/youtube_explode_dart.dart';

// Initialize the YoutubeExplode instance.
Expand Down Expand Up @@ -33,7 +32,7 @@ Future<void> download(String id) async {
final streams = manifest.audioOnly;

// Get the audio track with the highest bitrate.
final audio = streams.first;
final audio = streams.withHighestBitrate();
final audioStream = yt.videos.streamsClient.get(audio);

// Compose the file name removing the unallowed characters in windows.
Expand Down Expand Up @@ -65,16 +64,14 @@ Future<void> download(String id) async {
stdout.writeln(msg);

// Listen for data received.
final progressBar = ProgressBar();
await for (final data in audioStream) {
// Keep track of the current downloaded data.
count += data.length;

// Calculate the current progress.
final progress = ((count / len) * 100).ceil();

// Update the progressbar.
progressBar.update(progress);
print(progress.toStringAsFixed(2));

// Write to file.
output.add(data);
Expand Down
37 changes: 19 additions & 18 deletions lib/src/channels/channel.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ part of 'channel.dart';
T _$identity<T>(T value) => value;

final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');

/// @nodoc
mixin _$Channel {
Expand Down Expand Up @@ -103,10 +103,10 @@ class _$ChannelCopyWithImpl<$Res, $Val extends Channel>
}

/// @nodoc
abstract class _$$_ChannelCopyWith<$Res> implements $ChannelCopyWith<$Res> {
factory _$$_ChannelCopyWith(
_$_Channel value, $Res Function(_$_Channel) then) =
__$$_ChannelCopyWithImpl<$Res>;
abstract class _$$ChannelImplCopyWith<$Res> implements $ChannelCopyWith<$Res> {
factory _$$ChannelImplCopyWith(
_$ChannelImpl value, $Res Function(_$ChannelImpl) then) =
__$$ChannelImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
Expand All @@ -121,10 +121,11 @@ abstract class _$$_ChannelCopyWith<$Res> implements $ChannelCopyWith<$Res> {
}

/// @nodoc
class __$$_ChannelCopyWithImpl<$Res>
extends _$ChannelCopyWithImpl<$Res, _$_Channel>
implements _$$_ChannelCopyWith<$Res> {
__$$_ChannelCopyWithImpl(_$_Channel _value, $Res Function(_$_Channel) _then)
class __$$ChannelImplCopyWithImpl<$Res>
extends _$ChannelCopyWithImpl<$Res, _$ChannelImpl>
implements _$$ChannelImplCopyWith<$Res> {
__$$ChannelImplCopyWithImpl(
_$ChannelImpl _value, $Res Function(_$ChannelImpl) _then)
: super(_value, _then);

@pragma('vm:prefer-inline')
Expand All @@ -136,7 +137,7 @@ class __$$_ChannelCopyWithImpl<$Res>
Object? bannerUrl = null,
Object? subscribersCount = freezed,
}) {
return _then(_$_Channel(
return _then(_$ChannelImpl(
null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
Expand All @@ -163,8 +164,8 @@ class __$$_ChannelCopyWithImpl<$Res>

/// @nodoc
class _$_Channel extends _Channel {
const _$_Channel(
class _$ChannelImpl extends _Channel {
const _$ChannelImpl(
this.id, this.title, this.logoUrl, this.bannerUrl, this.subscribersCount)
: super._();

Expand Down Expand Up @@ -194,10 +195,10 @@ class _$_Channel extends _Channel {
}

@override
bool operator ==(dynamic other) {
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$_Channel &&
other is _$ChannelImpl &&
(identical(other.id, id) || other.id == id) &&
(identical(other.title, title) || other.title == title) &&
(identical(other.logoUrl, logoUrl) || other.logoUrl == logoUrl) &&
Expand All @@ -214,8 +215,8 @@ class _$_Channel extends _Channel {
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$_ChannelCopyWith<_$_Channel> get copyWith =>
__$$_ChannelCopyWithImpl<_$_Channel>(this, _$identity);
_$$ChannelImplCopyWith<_$ChannelImpl> get copyWith =>
__$$ChannelImplCopyWithImpl<_$ChannelImpl>(this, _$identity);
}

abstract class _Channel extends Channel {
Expand All @@ -224,7 +225,7 @@ abstract class _Channel extends Channel {
final String title,
final String logoUrl,
final String bannerUrl,
final int? subscribersCount) = _$_Channel;
final int? subscribersCount) = _$ChannelImpl;
const _Channel._() : super._();

@override
Expand All @@ -249,6 +250,6 @@ abstract class _Channel extends Channel {
int? get subscribersCount;
@override
@JsonKey(ignore: true)
_$$_ChannelCopyWith<_$_Channel> get copyWith =>
_$$ChannelImplCopyWith<_$ChannelImpl> get copyWith =>
throw _privateConstructorUsedError;
}
38 changes: 19 additions & 19 deletions lib/src/channels/channel_about.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ part of 'channel_about.dart';
T _$identity<T>(T value) => value;

final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');

/// @nodoc
mixin _$ChannelAbout {
Expand Down Expand Up @@ -114,11 +114,11 @@ class _$ChannelAboutCopyWithImpl<$Res, $Val extends ChannelAbout>
}

/// @nodoc
abstract class _$$_ChannelAboutCopyWith<$Res>
abstract class _$$ChannelAboutImplCopyWith<$Res>
implements $ChannelAboutCopyWith<$Res> {
factory _$$_ChannelAboutCopyWith(
_$_ChannelAbout value, $Res Function(_$_ChannelAbout) then) =
__$$_ChannelAboutCopyWithImpl<$Res>;
factory _$$ChannelAboutImplCopyWith(
_$ChannelAboutImpl value, $Res Function(_$ChannelAboutImpl) then) =
__$$ChannelAboutImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
Expand All @@ -132,11 +132,11 @@ abstract class _$$_ChannelAboutCopyWith<$Res>
}

/// @nodoc
class __$$_ChannelAboutCopyWithImpl<$Res>
extends _$ChannelAboutCopyWithImpl<$Res, _$_ChannelAbout>
implements _$$_ChannelAboutCopyWith<$Res> {
__$$_ChannelAboutCopyWithImpl(
_$_ChannelAbout _value, $Res Function(_$_ChannelAbout) _then)
class __$$ChannelAboutImplCopyWithImpl<$Res>
extends _$ChannelAboutCopyWithImpl<$Res, _$ChannelAboutImpl>
implements _$$ChannelAboutImplCopyWith<$Res> {
__$$ChannelAboutImplCopyWithImpl(
_$ChannelAboutImpl _value, $Res Function(_$ChannelAboutImpl) _then)
: super(_value, _then);

@pragma('vm:prefer-inline')
Expand All @@ -150,7 +150,7 @@ class __$$_ChannelAboutCopyWithImpl<$Res>
Object? country = freezed,
Object? channelLinks = null,
}) {
return _then(_$_ChannelAbout(
return _then(_$ChannelAboutImpl(
freezed == description
? _value.description
: description // ignore: cast_nullable_to_non_nullable
Expand Down Expand Up @@ -185,8 +185,8 @@ class __$$_ChannelAboutCopyWithImpl<$Res>

/// @nodoc
class _$_ChannelAbout implements _ChannelAbout {
const _$_ChannelAbout(
class _$ChannelAboutImpl implements _ChannelAbout {
const _$ChannelAboutImpl(
this.description,
this.viewCount,
this.joinDate,
Expand Down Expand Up @@ -246,10 +246,10 @@ class _$_ChannelAbout implements _ChannelAbout {
}

@override
bool operator ==(dynamic other) {
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$_ChannelAbout &&
other is _$ChannelAboutImpl &&
(identical(other.description, description) ||
other.description == description) &&
(identical(other.viewCount, viewCount) ||
Expand Down Expand Up @@ -278,8 +278,8 @@ class _$_ChannelAbout implements _ChannelAbout {
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$_ChannelAboutCopyWith<_$_ChannelAbout> get copyWith =>
__$$_ChannelAboutCopyWithImpl<_$_ChannelAbout>(this, _$identity);
_$$ChannelAboutImplCopyWith<_$ChannelAboutImpl> get copyWith =>
__$$ChannelAboutImplCopyWithImpl<_$ChannelAboutImpl>(this, _$identity);
}

abstract class _ChannelAbout implements ChannelAbout {
Expand All @@ -290,7 +290,7 @@ abstract class _ChannelAbout implements ChannelAbout {
final String title,
final List<Thumbnail> thumbnails,
final String? country,
final List<ChannelLink> channelLinks) = _$_ChannelAbout;
final List<ChannelLink> channelLinks) = _$ChannelAboutImpl;

@override

Expand Down Expand Up @@ -323,6 +323,6 @@ abstract class _ChannelAbout implements ChannelAbout {
List<ChannelLink> get channelLinks;
@override
@JsonKey(ignore: true)
_$$_ChannelAboutCopyWith<_$_ChannelAbout> get copyWith =>
_$$ChannelAboutImplCopyWith<_$ChannelAboutImpl> get copyWith =>
throw _privateConstructorUsedError;
}
10 changes: 7 additions & 3 deletions lib/src/channels/channel_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import '../reverse_engineering/pages/watch_page.dart';
import '../reverse_engineering/youtube_http_client.dart';
import '../videos/video.dart';
import '../videos/video_id.dart';
import 'channel_handle.dart';
import 'channels.dart';

/// Queries related to YouTube channels.
Expand Down Expand Up @@ -94,6 +93,8 @@ class ChannelClient {
/// Gets the info found on a YouTube Channel About page.
/// [username] must be either a [Username] or a string
/// which is parsed to a [Username]
///
/// WARNING: As of v2.2.0 this is broken due to yt updates.
Future<ChannelAbout> getAboutPageByUsername(dynamic username) async {
username = Username.fromString(username);

Expand Down Expand Up @@ -135,17 +136,20 @@ class ChannelClient {

/// Enumerates videos uploaded by the specified channel.
/// This fetches thru all the uploads pages of the channel.
/// The content by default is sorted by time of upload.
///
/// Use .nextPage() to fetch the next batch of videos.
Future<ChannelUploadsList> getUploadsFromPage(
dynamic channelId, [
dynamic channelId, {
VideoSorting videoSorting = VideoSorting.newest,
]) async {
VideoType videoType = VideoType.normal,
}) async {
channelId = ChannelId.fromString(channelId);
final page = await ChannelUploadPage.get(
_httpClient,
(channelId as ChannelId).value,
videoSorting.code,
videoType,
);

final channel = await get(channelId);
Expand Down
Loading

0 comments on commit 1444068

Please sign in to comment.