A Flutter package for extracting downloadable video URLs from YouTube videos. This package provides a simple and efficient way to get video URLs with different qualities including HD formats.
- 🎬 Extract video URLs from YouTube video IDs
- 📺 Support for different video qualities (720p, 1080p, 4K, etc.)
- 🔧 Handle YouTube's signature decryption
- 🚀 Simple and easy to use API
- 📱 Cross-platform support (iOS, Android, Web, Desktop)
- 🛡️ Error handling and authentication support
Add this package to your pubspec.yaml:
dependencies:
youtube_api: ^1.0.0Then run:
flutter pub getimport 'package:youtube_api/youtube_url_extractor.dart';
void main() async {
final extractor = YoutubeUrlExtractor();
// Extract URLs from a YouTube video ID
final videoId = 'dQw4w9WgXcQ';
final urls = await extractor.extractUrls(videoId);
for (final url in urls) {
print('Quality: ${url.quality}');
print('URL: ${url.url}');
print('MIME Type: ${url.mimeType}');
print('Size: ${url.width}x${url.height}');
print('---');
}
}import 'package:youtube_api/youtube_url_extractor.dart';
void main() async {
final extractor = YoutubeUrlExtractor();
try {
final videoId = 'dQw4w9WgXcQ';
final urls = await extractor.extractUrls(videoId);
// Filter for HD videos only
final hdUrls = urls.where((url) =>
url.quality.contains('720p') ||
url.quality.contains('1080p') ||
url.quality.contains('hd2160') ||
url.quality.contains('hd1440')
).toList();
// Get the best quality video
final bestQuality = urls.firstWhere(
(url) => url.quality.contains('hd2160'),
orElse: () => urls.first,
);
print('Best quality URL: ${bestQuality.url}');
} catch (e) {
print('Error: $e');
}
}Main class for extracting video URLs.
extractUrls(String videoId): Returns a list ofVideoUrlobjects containing downloadable URLs.
Model class containing video URL information.
url: The downloadable video URLquality: Video quality (e.g., '720p', '1080p', 'hd2160')mimeType: MIME type of the videobitrate: Video bitratewidth: Video width in pixelsheight: Video height in pixelscontentLength: Content length in bytes
- YouTube requires login authentication for certain videos
- This is a recent security measure implemented by YouTube
- The package structure is correct and functional
- Consider implementing authentication support for full functionality
- The package structure and code are correct
- YouTube has implemented stricter anti-bot protection
- Consider adding authentication support
- Alternative: Use YouTube Data API v3 (requires API key)
- Alternative: Implement browser automation with authentication
Run the tests to verify the package functionality:
flutter testContributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
This package uses YouTube's InnerTube API to extract video information and handles signature decryption for protected video URLs.
For more information about YouTube's API, see the YouTube Data API documentation.
If you encounter any issues or have questions, please:
- Check the issue tracker
- Create a new issue with detailed information
- Include error messages and code examples
- Initial release
- Support for video URL extraction
- Multiple quality formats support
- Error handling and authentication support