Tyrrrz / YoutubeExplode

Abstraction layer over YouTube's internal API
MIT License
2.93k stars 490 forks source link

BUG: crashes when fetching videos from channel which are having upcoming or premiering videos #831

Open SP-XD opened 18 hours ago

SP-XD commented 18 hours ago

Version

v2.3.1

Platform

Android

Steps to reproduce

Fetch a channel which is having an upcoming or premiering video

Details

Check the log below:

[log] onError(VideosBloc, FormatException: Invalid radix-10 number (at character 1)
      PREMIERE
      ^
      , #0      int._handleFormatError (dart:core-patch/integers_patch.dart:127:5)
      #1      int._parseRadix (dart:core-patch/integers_patch.dart:138:16)
integers_patch.dart:138
      #2      int._parse (dart:core-patch/integers_patch.dart:99:12)
integers_patch.dart:99
      #3      int.parse (dart:core-patch/integers_patch.dart:61:12)
integers_patch.dart:61
      #4      StringUtility.toDuration (package:youtube_explode_dart/src/extensions/helpers_extension.dart:69:36)
helpers_extension.dart:69
      #5      _InitialData._parseContent (package:youtube_explode_dart/src/reverse_engineering/pages/channel_upload_page.dart:204:17)
channel_upload_page.dart:204
      #6      MappedListIterable.elementAt (dart:_internal/iterable.dart:425:31)
iterable.dart:425
      #7      ListIterator.moveNext (dart:_internal/iterable.dart:354:26)
iterable.dart:354
      #8      NonNullsIterator.moveNext (dart:_internal/iterable.dart:921:20)
iterable.dart:921
      #9      new _GrowableList._ofOther (dart:core-patch/growable_array.dart:202:26)
growable_array.dart:202
      #10     new _GrowableList.of (dart:core-patch/growable_array.dart:152:26)
growable_array.dart:152
      #11     new List.of (dart:core-patch/array_patch.dart:39:18)
array_patch.dart:39
      #12     Iterable.toList (dart:core/iterable.dart:498:7)
iterable.dart:498
      #13     _InitialData._getUploads (package:youtube_explode_dart/src/reverse_engineering/pages/channel_upload_page.dart:75:48)
channel_upload_page.dart:75
      #14     _InitialData.uploads (package:youtube_explode_dart/src/reverse_engineering/pages/channel_upload_page.dart:68:43)
channel_upload_page.dart:68
      #15     _InitialData.uploads (package:youtube_explode_dart/src/reverse_engineering/pages/channel_upload_page.dart)
      #16     ChannelUploadPage.uploads (package:youtube_explode_dart/src/reverse_engineering/pages/channel_upload_page.dart:21:55)
channel_upload_page.dart:21
      #17     ChannelUploadPage.uploads (package:youtube_explode_dart/src/reverse_engineering/pages/channel_upload_page.dart)
      #18     ChannelClient.getUploadsFromPage (package:youtube_explode_dart/src/channels/channel_client.dart:158:12)
channel_client.dart:158
      <asynchronous suspension>
      #19     VideosRepository.getChannelVideos (package:midnight_suspense/src/data/repositories/videos_repository.dart:14:22)
videos_repository.dart:14
      <asynchronous suspension>
      #20     new VideosBloc.<anonymous closure>.<anonymous closure> (package:midnight_suspense/src/features/videos/bloc/videos_bloc.dart:21:22)
videos_bloc.dart:21
      <asynchronous suspension>
      #21     new VideosBloc.<anonymous closure> (package:midnight_suspense/src/features/videos/bloc/videos_bloc.dart:15:7)
videos_bloc.dart:15
      <asynchronous suspension>
      #22     Bloc.on.<anonymous closure>.handleEvent (package:bloc/src/bloc.dart:229:13)
bloc.dart:229
      <asynchronous suspension>
      )

Checklist

SP-XD commented 18 hours ago

I have added both UPCOMING and PREMIERE conditions locally but didn't get the time to test them, as it's hard to find channels with upcoming videos.

File:  youtube_explode_dart/src/extensions/helpers_extension.dart:59:5

  Duration? toDuration() {
    if (this == 'SHORTS' || this == "UPCOMING" || this == "PREMIERE" || trim().isEmpty) {
      return null;
    }
   ...
   }