refactor: Refactor code structure

This commit is contained in:
ihmily 2025-05-30 17:12:59 +08:00
parent 4fa3fbb773
commit 0bd2a3a360
24 changed files with 10 additions and 211 deletions

View File

@ -1,140 +0,0 @@
# StreamGet
`StreamGet` is a lightweight Python package designed to extract live stream URLs from live room links.
------
## Features
- **Extract Live Stream URLs**: Get direct video stream URLs by crawling the live room page and extracting the stream source interface.
- **Platform Support**: Works with popular live streaming platforms (e.g. Twitch, YouTube, Douyin, Xiaohongshu, Huya, Douyu, etc.).
- **No Dependencies**: Pure Python implementation with no external dependencies, ensuring lightweight and fast performance.
------
## Installation
Install `StreamGet` via pip:
```bash
pip install streamget
```
------
## Quick Start
```python
import asyncio
from streamget import spider, stream
async def main():
# Initialize with a live room URL
url = "https://live.douyin.com/745964462470"
# Get the live stream URL asynchronously
room_data = await spider.get_douyin_app_stream_data(url)
print('room_data:', room_data)
stream_data = await stream.get_douyin_stream_url(room_data, '0')
print('stream_data :', stream_data)
stream_url = stream_data.get('record_url')
print("Live Stream URL:", stream_url)
# Run the async function
asyncio.run(main())
```
------
## Supported Platforms
| Platform | Support status | HLS support | FLV support |
| :---------- | :------------- | :---------- | :---------- |
| 抖音 | ✅ | ✅ | ✅ |
| TikTok | ✅ | ✅ | ✅ |
| 快手 | ✅ | ❌ | ✅ |
| 虎牙 | ✅ | ✅ | ✅ |
| 斗鱼 | ✅ | ❌ | ✅ |
| YY | ✅ | ❌ | ✅ |
| B站 | ✅ | ❌ | ✅ |
| 小红书 | ✅ | ✅ | ✅ |
| Bigo | ✅ | ✅ | ❌ |
| Blued | ✅ | ✅ | ❌ |
| SOOP | ✅ | ✅ | ❌ |
| 网易CC | ✅ | ✅ | ✅ |
| 千度热播 | ✅ | ❌ | ✅ |
| PandaTV | ✅ | ✅ | ❌ |
| 猫耳FM | ✅ | ✅ | ✅ |
| Look直播 | ✅ | ✅ | ✅ |
| WinkTV | ✅ | ✅ | ❌ |
| FlexTV | ✅ | ✅ | ❌ |
| PopkonTV | ✅ | ✅ | ❌ |
| TwitCasting | ✅ | ✅ | ❌ |
| 百度直播 | ✅ | ✅ | ✅ |
| 微博直播 | ✅ | ✅ | ✅ |
| 酷狗直播 | ✅ | ❌ | ✅ |
| TwitchTV | ✅ | ✅ | ❌ |
| LiveMe | ✅ | ✅ | ✅ |
| 花椒直播 | ✅ | ❌ | ✅ |
| 流星直播 | ✅ | ❌ | ✅ |
| ShowRoom | ✅ | ✅ | ❌ |
| Acfun | ✅ | ✅ | ✅ |
| 映客直播 | ✅ | ✅ | ✅ |
| 音播直播 | ✅ | ✅ | ✅ |
| 知乎直播 | ✅ | ✅ | ✅ |
| CHZZK | ✅ | ✅ | ❌ |
| 嗨秀直播 | ✅ | ❌ | ✅ |
| vv星球直播 | ✅ | ✅ | ❌ |
| 17Live | ✅ | ❌ | ✅ |
| 浪Live | ✅ | ✅ | ✅ |
| 畅聊直播 | ✅ | ✅ | ✅ |
| 飘飘直播 | ✅ | ✅ | ✅ |
| 六间房直播 | ✅ | ❌ | ✅ |
| 乐嗨直播 | ✅ | ✅ | ✅ |
| 花猫直播 | ✅ | ✅ | ❌ |
| Shopee | ✅ | ❌ | ✅ |
| YouTube | ✅ | ✅ | ❌ |
| 淘宝 | ✅ | ✅ | ✅ |
| 京东 | ✅ | ✅ | ✅ |
| Faceit | ✅ | ✅ | ❌ |
| More ... | | | |
### Notes:
1. **Support Status**: ✅ indicates supported, ❌ indicates unsupported.
------
## Supported Quality
| Chinese clarity | abbreviation | Full Name | Note |
| :-------------- | :----------- | :-------------------- | :------------------------------------------------- |
| 原画 | `OD` | Original Definition | Highest clarity, original picture quality |
| 蓝光 | `BD` | Blue-ray Definition | High definition close to blue light quality |
| 超清 | `UHD` | Ultra High Definition | Ultra high definition |
| 高清 | `HD` | High Definition | High definition, usually referring to 1080p |
| 标清 | `SD` | Standard Definition | Standard clarity, usually referring to 480p |
| 流畅 | `LD` | Low Definition | Low definition, usually referring to 360p or lower |
## Contributing
Contributions are welcome! If you'd like to add support for a new platform or improve the package, please check out the [GitHub repository](https://github.com/ihmily/DouyinLiveRecorder) and submit a pull request.
------
## License
`StreamGet` is released under the MIT License. See the [LICENSE](https://github.com/ihmily/DouyinLiveRecorder/blob/main/LICENSE) file for details.
------
## Documentation
For full documentation and advanced usage, visit the [official documentation](https://streamget.readthedocs.io/).
------

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
import asyncio
from streamget.logger import logger
from streamget import spider
from src.logger import logger
from src import spider
# 以下示例直播间链接不保证时效性,请自行查看链接是否能正常访问
# Please note that the following example live room links may not be up-to-date

View File

@ -15,7 +15,7 @@ import zipfile
from pathlib import Path
import requests
from tqdm import tqdm
from streamget.logger import logger
from src.logger import logger
current_platform = platform.system()
execute_dir = os.path.split(os.path.realpath(sys.argv[0]))[0]

View File

@ -20,7 +20,7 @@ else:
locale_path = Path(execute_dir) / 'i18n'
_tr = init_gettext(locale_path, 'zh_CN')
original_print = builtins.print
package_name = 'streamget'
package_name = 'src'
def translated_print(*args, **kwargs):

View File

@ -27,10 +27,10 @@ import urllib.request
from urllib.error import URLError, HTTPError
from typing import Any
import configparser
from streamget import spider, stream
from streamget.proxy import ProxyDetector
from streamget.utils import logger
from streamget import utils
from src import spider, stream
from src.proxy import ProxyDetector
from src.utils import logger
from src import utils
from msg_push import (
dingtalk, xizhi, tg_bot, send_email, bark, ntfy
)

View File

@ -1,4 +0,0 @@
[virtualenvs]
in-project = true
create = true
prefer-active-python = true

View File

@ -1,24 +0,0 @@
[project]
name = "streamget"
version = "4.0.3"
description = "A simple and efficient tool to fetch live stream URLs from various platforms. Supports multiple platforms and easy integration."
authors = [{ name = "Hmily" }]
license = {text = "MIT"}
readme = "README_PYPI.md"
urls = {Repository = "https://github.com/ihmily/DouyinLiveRecorder"}
keywords = ["douyin", "youtube", "tiktok", "twitch", "live", "recorder"]
requires-python = ">=3.10,<4.0"
dependencies = [
"requests>=2.31.0",
"loguru>=0.7.3",
"pycryptodome>=3.20.0",
"distro>=1.9.0",
"tqdm>=4.67.1",
"httpx[http2]>=0.28.1",
"PyExecJS>=1.5.1"
]
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

View File

@ -1,33 +0,0 @@
# -*- coding: utf-8 -*-
from setuptools import setup, find_packages
setup(
name='streamget',
version='4.0.3',
author='Hmily',
description='A simple and efficient tool to fetch live stream URLs from various platforms. Supports multiple '
'platforms and easy integration.',
long_description=open('README_PYPI.md', encoding='utf-8').read(),
long_description_content_type='text/markdown',
url='https://github.com/ihmily/DouyinLiveRecorder',
packages=find_packages(),
install_requires=[
'requests>=2.31.0',
'loguru>=0.7.3',
'pycryptodome>=3.20.0',
'distro>=1.9.0',
'tqdm>=4.67.1',
'httpx[http2]>=0.28.1'
'PyExecJS>=1.5.1',
],
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
]
)

View File

@ -37,7 +37,7 @@ async def async_req(
return str(response.url)
elif return_cookies:
cookies_dict = {name: value for name, value in response.cookies.items()}
return response.text, cookies_dict if include_cookies else cookies_dict
return (response.text, cookies_dict) if include_cookies else cookies_dict
else:
resp_str = response.text
except Exception as e: