Hexer10 / youtube_explode_dart

Dart library to interact with many Youtube APIs
https://pub.dev/packages/youtube_explode_dart
BSD 3-Clause "New" or "Revised" License
322 stars 141 forks source link

[BUG] publishDate and uploadDate in playlist return null #183

Closed isa-sabbagh closed 2 years ago

isa-sabbagh commented 2 years ago

Describe the bug publishDate and uploadDate in playlist return null all the time

void _getList() async {
    setState(() => _isLoading = true);
    try {
      var yt = YoutubeExplode();

      // Get playlist metadata.
      var playlist = await yt.playlists.get('https://www.youtube.com/playlist?list=PLDoPjvoNmBAzH72MTPuAAaYfReraNlQgM');

      await for (var video in yt.playlists.getVideos(playlist.id)) {
        print(video.publishDate); // retren null 
        setState(() {
          _videosList.add(YoutubeVideo(
            id: video.id.toString(),
            image: video.thumbnails.lowResUrl,
            title: video.title,
            url: video.url,
            videoPublishedAt: video.publishDate ?? video.uploadDate ?? DateTime.now(),
          ));
        });
      }
    } finally {
      setState(() => _isLoading = false);
    }
  }
Hexer10 commented 2 years ago

That is the intended behavior unfortunately; as you can see in the playlist page youtube doesn't provide any publish or upload date.