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

I can't download captions with package:googleapis/youtube/v3.dart #631

Closed
najm-flutter opened this issue Jun 19, 2024 · 1 comment
Closed

Comments

@najm-flutter
Copy link

najm-flutter commented Jun 19, 2024

the Error :
DetailedApiRequestError (DetailedApiRequestError(status: 400, message: Unsupported Output Format))

the code :

import 'package:extension_google_sign_in_as_googleapis_auth/extension_google_sign_in_as_googleapis_auth.dart';
import 'package:flutter/material.dart';
import 'package:google_sign_in/google_sign_in.dart';
import 'package:googleapis/youtube/v3.dart' as youtube;

class Test extends StatelessWidget {
  const Test({super.key});
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: [
          MaterialButton(
              color: Colors.amber,
              onPressed: () async {
                final googleSignIn = GoogleSignIn(
                  scopes: <String>[youtube.YouTubeApi.youtubepartnerScope, youtube.YouTubeApi.youtubeForceSslScope],
                );
                if (!await googleSignIn.isSignedIn()) {
                  await googleSignIn.signIn();
                } else {
                  await googleSignIn.signInSilently();
                }

                var httpClient = (await googleSignIn.authenticatedClient())!;

                var api = youtube.YouTubeApi(httpClient);

                // Replace '<VIDEO_ID>' with the ID of the YouTube video
                var captions = await api.captions.list(["snippet"], 'fatb7Clc0MM');

                for (var caption in captions.items!) {
                  print('Caption ID: ${caption.id}');
                  print('Language: ${caption.snippet!.language}');
                  print('status: ${caption.snippet!.status}');
                  print('isEasyReader: ${caption.snippet!.isEasyReader}');
              }
             var fff = await api.captions.download(captions.items![0].id! ) ;
             print(fff?.contentType);
                //   // Fetch the actual caption content
               
              })
        ],
      ),
    );
  }
}
@kevmoo
Copy link
Collaborator

kevmoo commented Dec 28, 2024

I'd dig in here: https://developers.google.com/youtube/v3/docs

This package just exposes the underlying API. Please reopen if there is a bug in how the underlying API is exposed.

@kevmoo kevmoo closed this as completed Dec 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants