gumphp/parse-video
Composer 安装命令:
composer require gumphp/parse-video
包简介
A PHP library to parse video information from various Chinese social media platforms
README 文档
README
A PHP library to parse video information from various Chinese social media platforms. This is the PHP equivalent of the popular Python parse-video-py library.
Features
- Parse video information from 20+ Chinese social media platforms
- Extract direct video URLs, thumbnails, titles, and author information
- Support for both video and image album parsing where applicable
- Modern PHP 8.1+ with strict typing
- PSR-4 autoloading and composer support
- Built with Guzzle HTTP client for reliable requests
Supported Platforms
- Douyin (抖音) - including image albums and Live Photos
- Kuaishou (快手)
- Weibo (微博) - including image albums
- Bilibili (哔哩哔哩)
- Xiaohongshu (小红书)
- PiPiXia (皮皮虾)
- WeiShi (微视)
- LvZhou (绿洲)
- ZuiYou (最右)
- QuanMin (度小视/原 全民小视频)
- XiGua (西瓜视频)
- LiShiPin (梨视频)
- PiPiGaoXiao (皮皮搞笑)
- HuYa (虎牙)
- AcFun (A站)
- DouPai (逗拍)
- MeiPai (美拍)
- QuanMinKGe (全民K歌)
- SixRoom (六间房)
- XinPianChang (新片场)
- HaoKan (好看视频)
Installation
composer require gumphp/parse-video
Requirements
- PHP >= 8.1
- ext-json
- ext-curl
- guzzlehttp/guzzle
Usage
Basic Usage
<?php require_once 'vendor/autoload.php'; use GumPHP\VideoParser\VideoParser; use GumPHP\VideoParser\Enum\VideoSource; $parser = new VideoParser(); // Parse from share URL try { $videoInfo = $parser->parseShareUrl('https://v.douyin.com/abc123'); echo "Video URL: " . $videoInfo->getVideoUrl() . "\n"; echo "Cover URL: " . $videoInfo->getCoverUrl() . "\n"; echo "Title: " . $videoInfo->getTitle() . "\n"; echo "Author: " . $videoInfo->getAuthor()->getName() . "\n"; // For image albums foreach ($videoInfo->getImages() as $image) { echo "Image URL: " . $image->getUrl() . "\n"; if ($image->getLivePhotoUrl()) { echo "Live Photo URL: " . $image->getLivePhotoUrl() . "\n"; } } } catch (\Exception $e) { echo "Error: " . $e->getMessage() . "\n"; } // Parse from video ID try { $videoInfo = $parser->parseVideoId(VideoSource::DOUYIN, 'abc123'); // ... same usage as above } catch (\Exception $e) { echo "Error: " . $e->getMessage() . "\n"; }
Check if URL is Supported
$parser = new VideoParser(); if ($parser->isUrlSupported('https://v.douyin.com/abc123')) { echo "URL is supported!\n"; } $source = $parser->detectVideoSource('https://v.douyin.com/abc123'); if ($source) { echo "Detected source: " . $source->value . "\n"; }
Get All Supported Sources
$parser = new VideoParser(); $sources = $parser->getSupportedSources(); foreach ($sources as $source => $domains) { echo "Source: {$source}, Domains: " . implode(', ', $domains) . "\n"; }
Data Structures
VideoInfo
class VideoInfo { public string $videoUrl; // Direct video URL public string $coverUrl; // Video thumbnail public string $title; // Video title public string $musicUrl; // Background music URL public array $images; // Array of ImgInfo for image albums public VideoAuthor $author; // Author information }
VideoAuthor
class VideoAuthor { public string $uid; // Author ID public string $name; // Author name public string $avatar; // Author avatar URL }
ImgInfo (for Image Albums)
class ImgInfo { public string $url; // Image URL public string $livePhotoUrl; // Live Photo video URL (if available) }
Error Handling
The library throws specific exceptions for different error conditions:
use GumPHP\VideoParser\Exception\ParseException; use GumPHP\VideoParser\Exception\UnsupportedSourceException; try { $videoInfo = $parser->parseShareUrl($url); } catch (UnsupportedSourceException $e) { // URL is from an unsupported platform echo "Unsupported platform: " . $e->getMessage(); } catch (ParseException $e) { // Parsing failed (video not found, API changed, etc.) echo "Parsing failed: " . $e->getMessage(); } catch (\Exception $e) { // Other errors (network issues, etc.) echo "Error: " . $e->getMessage(); }
Development
Running Tests
composer test
Static Analysis
composer analyse
Architecture
The library follows a modular architecture similar to the Python version:
- VideoParser - Main service class for parsing URLs
- BaseParser - Abstract base class for platform-specific parsers
- Platform Parsers - Individual parser classes for each platform
- Models - Data classes for video information, author info, etc.
- Enums - Enumerations for video sources
- Exceptions - Custom exception classes
Adding New Platforms
- Create a new parser class extending
BaseParser - Add the source to the
VideoSourceenum - Update the parser mapping in
VideoParser.php - Implement the required
parseShareUrl()andparseVideoId()methods
Example:
<?php namespace GumPHP\VideoParser\Parser; use GumPHP\VideoParser\Exception\ParseException; use GumPHP\VideoParser\Model\VideoInfo; class NewPlatform extends BaseParser { public function parseShareUrl(string $shareUrl): VideoInfo { // Implementation here } public function parseVideoId(string $videoId): VideoInfo { // Implementation here } }
License
MIT License
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Acknowledgments
This library is heavily inspired by and aims to provide PHP equivalent functionality to the parse-video-py Python library.
gumphp/parse-video 适用场景与选型建议
gumphp/parse-video 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 11 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「parser」 「video」 「weibo」 「bilibili」 「kuaishou」 「douyin」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 gumphp/parse-video 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gumphp/parse-video 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 gumphp/parse-video 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Easy to use SDK with grabber for multiple platforms at once like YouTube, Dailymotion, Facebook and more.
An MT940 bank statement parser for PHP
The yii2-videojs-widget is a Yii 2 wrapper for the [video.js](http://www.videojs.com/). A JavaScript and CSS library that makes it easier to work with and build on HTML5 video. This is also known as an HTML5 Video Player.
Display a video using native HTML5 video
Laravel integration for the jsonapi.org parser
Weibo image uploader.
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 29
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-06