Code style
This commit is contained in:
parent
d56eabc554
commit
5beeed2387
|
@ -6,17 +6,60 @@ include: package:effective_dart/analysis_options.yaml
|
|||
# For lint rules and documentation, see http://dart-lang.github.io/linter/lints.
|
||||
# Uncomment to specify additional rules.
|
||||
linter:
|
||||
rules:
|
||||
- valid_regexps
|
||||
- prefer_const_constructors
|
||||
- prefer_const_declarations
|
||||
- prefer_const_literals_to_create_immutables
|
||||
- prefer_constructors_over_static_methods
|
||||
- prefer_contains
|
||||
- annotate_overrides
|
||||
- await_only_futures
|
||||
- unawaited_futures
|
||||
rules:
|
||||
- valid_regexps
|
||||
- prefer_const_constructors
|
||||
- prefer_const_declarations
|
||||
- prefer_const_literals_to_create_immutables
|
||||
- prefer_constructors_over_static_methods
|
||||
- prefer_contains
|
||||
- annotate_overrides
|
||||
- await_only_futures
|
||||
- unawaited_futures
|
||||
- avoid_empty_else
|
||||
- avoid_returning_null_for_future
|
||||
- avoid_types_as_parameter_names
|
||||
- control_flow_in_finally
|
||||
- empty_statements
|
||||
- invariant_booleans
|
||||
- iterable_contains_unrelated_type
|
||||
- list_remove_unrelated_type
|
||||
- literal_only_boolean_expressions
|
||||
- no_adjacent_strings_in_list
|
||||
- no_duplicate_case_values
|
||||
- prefer_void_to_null
|
||||
- test_types_in_equals
|
||||
- throw_in_finally
|
||||
- unnecessary_statements
|
||||
- unrelated_type_equality_checks
|
||||
- always_declare_return_types
|
||||
- always_put_control_body_on_new_line
|
||||
- avoid_returning_null_for_void
|
||||
- avoid_setters_without_getters
|
||||
- avoid_shadowing_type_parameters
|
||||
- avoid_unnecessary_containers
|
||||
- avoid_void_async
|
||||
- empty_catches
|
||||
- null_closures
|
||||
- prefer_conditional_assignment
|
||||
- prefer_if_null_operators
|
||||
- prefer_is_empty
|
||||
- prefer_is_not_empty
|
||||
- prefer_is_not_operator
|
||||
- prefer_null_aware_operators
|
||||
- recursive_getters
|
||||
- unnecessary_await_in_return
|
||||
- unnecessary_null_aware_assignments
|
||||
- unnecessary_null_in_if_null_operators
|
||||
- unnecessary_overrides
|
||||
- unnecessary_parenthesis
|
||||
- unnecessary_raw_strings
|
||||
- unnecessary_string_escapes
|
||||
- unnecessary_string_interpolations
|
||||
- use_string_buffers
|
||||
- void_checks
|
||||
- package_names
|
||||
|
||||
analyzer:
|
||||
exclude:
|
||||
- example\**
|
||||
exclude:
|
||||
- example\**
|
||||
|
|
|
@ -45,7 +45,7 @@ class ChannelClient {
|
|||
var playerResponse = videoInfoResponse.playerResponse;
|
||||
|
||||
var channelId = playerResponse.videoChannelId;
|
||||
return await get(ChannelId(channelId));
|
||||
return get(ChannelId(channelId));
|
||||
}
|
||||
|
||||
/// Enumerates videos uploaded by the specified channel.
|
||||
|
|
|
@ -28,7 +28,7 @@ class ChannelId extends Equatable {
|
|||
return false;
|
||||
}
|
||||
|
||||
return !RegExp('[^0-9a-zA-Z_\-]').hasMatch(id);
|
||||
return !RegExp(r'[^0-9a-zA-Z_\-]').hasMatch(id);
|
||||
}
|
||||
|
||||
/// Parses a channel id from an url.
|
||||
|
@ -61,7 +61,7 @@ class ChannelId extends Equatable {
|
|||
}
|
||||
|
||||
@override
|
||||
String toString() => '$value';
|
||||
String toString() => value;
|
||||
|
||||
@override
|
||||
List<Object> get props => [value];
|
||||
|
|
|
@ -32,6 +32,7 @@ class PlaylistClient {
|
|||
id = PlaylistId.fromString(id);
|
||||
var encounteredVideoIds = <String>{};
|
||||
var index = 0;
|
||||
// ignore: literal_only_boolean_expressions
|
||||
while (true) {
|
||||
var response =
|
||||
await PlaylistResponse.get(_httpClient, id.value, index: index);
|
||||
|
|
|
@ -5,7 +5,7 @@ class PlaylistId {
|
|||
static final _regMatchExp =
|
||||
RegExp(r'youtube\..+?/playlist.*?list=(.*?)(?:&|/|$)');
|
||||
static final _compositeMatchExp = RegExp(
|
||||
r'https://www.youtube.com/watch?v=b8m9zhNAgKs&list=PL9tY0BWXOZFuFEG_GtOBZ8-8wbkH-NVAr');
|
||||
'https://www.youtube.com/watch?v=b8m9zhNAgKs&list=PL9tY0BWXOZFuFEG_GtOBZ8-8wbkH-NVAr');
|
||||
static final _shortCompositeMatchExp =
|
||||
RegExp(r'youtu\.be/.*?/.*?list=(.*?)(?:&|/|$)');
|
||||
static final _embedCompositeMatchExp =
|
||||
|
|
|
@ -9,6 +9,7 @@ import 'exceptions/exceptions.dart';
|
|||
Future<T> retry<T>(FutureOr<T> function()) async {
|
||||
var retryCount = 5;
|
||||
|
||||
// ignore: literal_only_boolean_expressions
|
||||
while (true) {
|
||||
try {
|
||||
return await function();
|
||||
|
|
|
@ -108,23 +108,4 @@ class _StreamInfo extends StreamInfoProvider {
|
|||
|
||||
@override
|
||||
int get framerate => int.tryParse(_root['fps'] ?? '');
|
||||
}
|
||||
|
||||
extension on String {
|
||||
String get nullIfWhitespace => trim().isEmpty ? null : this;
|
||||
|
||||
bool get isNullOrWhiteSpace {
|
||||
if (this == null) {
|
||||
return true;
|
||||
}
|
||||
if (trim().isEmpty) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
String substringUntil(String separator) => substring(0, indexOf(separator));
|
||||
|
||||
String substringAfter(String separator) =>
|
||||
substring(indexOf(separator) + length);
|
||||
}
|
||||
}
|
|
@ -43,9 +43,9 @@ class StreamsClient {
|
|||
await PlayerSource.get(_httpClient, playerConfig.sourceUrl);
|
||||
var cipherOperations = playerSource.getCiperOperations();
|
||||
|
||||
var videoInfoReponse = await VideoInfoResponse.get(
|
||||
var videoInfoResponse = await VideoInfoResponse.get(
|
||||
_httpClient, videoId.toString(), playerSource.sts);
|
||||
var playerResponse = videoInfoReponse.playerResponse;
|
||||
var playerResponse = videoInfoResponse.playerResponse;
|
||||
|
||||
var previewVideoId = playerResponse.previewVideoId;
|
||||
if (!previewVideoId.isNullOrWhiteSpace) {
|
||||
|
@ -63,7 +63,7 @@ class StreamsClient {
|
|||
}
|
||||
|
||||
var streamInfoProviders = <StreamInfoProvider>[
|
||||
...videoInfoReponse.streams,
|
||||
...videoInfoResponse.streams,
|
||||
...playerResponse.streams
|
||||
];
|
||||
|
||||
|
|
|
@ -48,9 +48,9 @@ void main() {
|
|||
});
|
||||
|
||||
test('GetMetadataOfInvalidVideo', () async {
|
||||
expect(() async => await yt.videos.get(VideoId('qld9w0b-1ao')),
|
||||
expect(() async => yt.videos.get(VideoId('qld9w0b-1ao')),
|
||||
throwsA(const TypeMatcher<VideoUnplayableException>()));
|
||||
expect(() async => await yt.videos.get(VideoId('pb_hHv3fByo')),
|
||||
expect(() async => yt.videos.get(VideoId('pb_hHv3fByo')),
|
||||
throwsA(const TypeMatcher<VideoUnplayableException>()));
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue