youtube_id_scraper 1.0.4 copy "youtube_id_scraper: ^1.0.4" to clipboard
youtube_id_scraper: ^1.0.4 copied to clipboard

A package to extract YouTube video IDs and other details from URLs.

example/lib/main.dart

import 'package:flutter/material.dart';

// Import the package
import 'package:youtube_id_scraper/youtube_id_scraper.dart';

// The main function
void main() {
  runApp(MaterialApp(
    home: Scaffold(
      appBar: AppBar(
        title: const Text("YouTube ID Scraper"),
      ),
      body: const MainAppStart(),
    ),
  ));
}

// A stateful widget to define the application's main start point
class MainAppStart extends StatefulWidget {
  const MainAppStart({Key? key}) : super(key: key);

  @override
  State<MainAppStart> createState() => _MainAppStartState();
}

// The state class
class _MainAppStartState extends State<MainAppStart> {
  // Create an instance of the YouTubeIDScraper
  YouTubeIDScraper ytscrab = YouTubeIDScraper();

  // Define the YouTube video URL
  String url = "https://www.youtube.com/watch?v=abcdefghijk";

  @override
  Widget build(BuildContext context) {
    // Access the getVideoID method to extract video details
    var videoDetails = ytscrab.getVideoID(url);
    return Container(
      padding: const EdgeInsets.all(10),
      child: Column(
        children: [
          Row(
            children: [
              const Text("Video ID: "),
              Text(videoDetails.id ??
                  "Unable to get Video ID"), // Print "Unable to get Video ID" if video id is null
            ],
          ),
          Row(
            children: [
              const Text("Video URL: "),
              Text(videoDetails.videoURL ??
                  "Unable to get Video URL"), // Print "Unable to get Video URL" if video URL is null
            ],
          ),
          Row(
            children: [
              const Text("Error Log: "),
              Text(videoDetails.errorLog ??
                  "No Error"), // Print "No Error" if it's a valid URL; otherwise, print the error log
            ],
          ),
          Row(
            children: [
              const Text("Error Description: "),
              Text(videoDetails.errorDescription ??
                  "No Error"), // Print "No Error" if it's a valid URL; otherwise, print the error description
            ],
          ),
          Row(
            children: [
              const Text("URL Type: "),
              Text(videoDetails.urlType ??
                  "Unable to get URL Type"), // Print "Unable to get URL Type" if any error occurs
            ],
          ),
        ],
      ),
    );
  }
}
5
likes
140
pub points
48%
popularity

Publisher

verified publisherrabi.info.np

A package to extract YouTube video IDs and other details from URLs.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on youtube_id_scraper