repo_full_name stringlengths 6 93 | repo_url stringlengths 25 112 | repo_api_url stringclasses 28
values | owner stringclasses 28
values | repo_name stringclasses 28
values | description stringclasses 28
values | stars int64 617 98.8k | forks int64 31 355 ⌀ | watchers int64 990 999 ⌀ | license stringclasses 2
values | default_branch stringclasses 2
values | repo_created_at timestamp[s]date 2012-07-24 23:12:50 2025-06-16 08:07:28 ⌀ | repo_updated_at timestamp[s]date 2026-02-23 15:23:15 2026-05-03 18:52:12 ⌀ | repo_topics listlengths 0 13 ⌀ | repo_languages unknown | is_fork bool 1
class | open_issues int64 3 104 ⌀ | file_path stringlengths 3 208 | file_name stringclasses 509
values | file_extension stringclasses 1
value | file_size_bytes int64 101 84k ⌀ | file_url stringclasses 627
values | file_raw_url stringclasses 627
values | file_sha stringclasses 624
values | language stringclasses 8
values | parsed_at stringdate 2026-05-04 01:12:36 2026-05-04 19:41:55 | text stringlengths 100 102k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ollama/ollama-python | https://github.com/ollama/ollama-python | null | null | null | null | 9,917 | null | null | mit | null | null | null | null | null | null | null | tests/test_type_serialization.py | null | null | null | null | null | null | Python | 2026-05-04T02:02:46.994091 | import tempfile
from base64 import b64encode
from pathlib import Path
import pytest
from ollama._types import CreateRequest, Image
def test_image_serialization_bytes():
image_bytes = b'test image bytes'
encoded_string = b64encode(image_bytes).decode()
img = Image(value=image_bytes)
assert img.model_dump() =... |
ollama/ollama-python | https://github.com/ollama/ollama-python | null | null | null | null | 9,917 | null | null | mit | null | null | null | null | null | null | null | tests/test_utils.py | null | null | null | null | null | null | Python | 2026-05-04T02:02:47.022800 | import json
import sys
from typing import Dict, List, Mapping, Sequence, Set, Tuple, Union
from ollama._utils import convert_function_to_tool
def test_function_to_tool_conversion():
def add_numbers(x: int, y: Union[int, None] = None) -> int:
"""Add two numbers together.
args:
x (integer): The first... |
ihmily/DouyinLiveRecorder | https://github.com/ihmily/DouyinLiveRecorder | null | null | null | null | 9,905 | null | null | mit | null | null | null | null | null | null | null | src/http_clients/sync_http.py | null | null | null | null | null | null | Python | 2026-05-04T02:02:49.524293 | # -*- coding: utf-8 -*-
import gzip
import urllib.parse
import urllib.error
import requests
import ssl
import json
import urllib.request
no_proxy_handler = urllib.request.ProxyHandler({})
opener = urllib.request.build_opener(no_proxy_handler)
ssl_context = ssl.create_default_context()
ssl_context.check_hostname = Fal... |
ihmily/DouyinLiveRecorder | https://github.com/ihmily/DouyinLiveRecorder | null | null | null | null | 9,905 | null | null | mit | null | null | null | null | null | null | null | ffmpeg_install.py | null | null | null | null | null | null | Python | 2026-05-04T02:02:49.551946 | # -*- coding: utf-8 -*-
"""
Author: Hmily
GitHub: https://github.com/ihmily
Copyright (c) 2024 by Hmily, All Rights Reserved.
"""
import os
import re
import subprocess
import sys
import platform
import zipfile
from pathlib import Path
import requests
from tqdm import tqdm
from src.logger import logger
current_platfo... |
ihmily/DouyinLiveRecorder | https://github.com/ihmily/DouyinLiveRecorder | null | null | null | null | 9,905 | null | null | mit | null | null | null | null | null | null | null | demo.py | null | null | null | null | null | null | Python | 2026-05-04T02:02:49.553684 | # -*- coding: utf-8 -*-
import asyncio
from src.logger import logger
from src import spider
# 以下示例直播间链接不保证时效性,请自行查看链接是否能正常访问
# Please note that the following example live room links may not be up-to-date
LIVE_STREAM_CONFIG = {
"douyin": {
"url": "https://live.douyin.com/745964462470",
"func": spide... |
ihmily/DouyinLiveRecorder | https://github.com/ihmily/DouyinLiveRecorder | null | null | null | null | 9,905 | null | null | mit | null | null | null | null | null | null | null | i18n.py | null | null | null | null | null | null | Python | 2026-05-04T02:02:49.555107 | import os
import sys
import gettext
import inspect
import builtins
from pathlib import Path
def init_gettext(locale_dir, locale_name):
gettext.bindtextdomain('zh_CN', locale_dir)
gettext.textdomain('zh_CN')
os.environ['LANG'] = f'{locale_name}.utf8'
return gettext.gettext
execute_dir = os.path.split... |
ihmily/DouyinLiveRecorder | https://github.com/ihmily/DouyinLiveRecorder | null | null | null | null | 9,905 | null | null | mit | null | null | null | null | null | null | null | src/initializer.py | null | null | null | null | null | null | Python | 2026-05-04T02:02:49.567503 | # -*- coding: utf-8 -*-
"""
Author: Hmily
GitHub:https://github.com/ihmily
Copyright (c) 2024 by Hmily, All Rights Reserved.
"""
import os
import subprocess
import sys
import platform
import zipfile
from pathlib import Path
import requests
import re
import distro
from tqdm import tqdm
from .logger import logger
curr... |
ihmily/DouyinLiveRecorder | https://github.com/ihmily/DouyinLiveRecorder | null | null | null | null | 9,905 | null | null | mit | null | null | null | null | null | null | null | msg_push.py | null | null | null | null | null | null | Python | 2026-05-04T02:02:49.569106 | # -*- coding: utf-8 -*-
"""
Author: Hmily
GitHub: https://github.com/ihmily
Date: 2023-09-03 19:18:36
Update: 2025-01-23 17:16:12
Copyright (c) 2023-2024 by Hmily, All Rights Reserved.
"""
from typing import Dict, Any
import json
import base64
import urllib.request
import urllib.error
import smtplib
from email.header ... |
ihmily/DouyinLiveRecorder | https://github.com/ihmily/DouyinLiveRecorder | null | null | null | null | 9,905 | null | null | mit | null | null | null | null | null | null | null | src/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T02:02:49.577975 | import os
import sys
from pathlib import Path
from .initializer import check_node
current_file_path = Path(__file__).resolve()
current_dir = current_file_path.parent
JS_SCRIPT_PATH = current_dir / 'javascript'
execute_dir = os.path.split(os.path.realpath(sys.argv[0]))[0]
node_execute_dir = Path(execute_dir) / 'node'
... |
ihmily/DouyinLiveRecorder | https://github.com/ihmily/DouyinLiveRecorder | null | null | null | null | 9,905 | null | null | mit | null | null | null | null | null | null | null | src/http_clients/async_http.py | null | null | null | null | null | null | Python | 2026-05-04T02:02:49.578435 | # -*- coding: utf-8 -*-
import httpx
from typing import Dict, Any
from .. import utils
OptionalStr = str | None
OptionalDict = Dict[str, Any] | None
async def async_req(
url: str,
proxy_addr: OptionalStr = None,
headers: OptionalDict = None,
data: dict | bytes | None = None,
j... |
ihmily/DouyinLiveRecorder | https://github.com/ihmily/DouyinLiveRecorder | null | null | null | null | 9,905 | null | null | mit | null | null | null | null | null | null | null | src/ab_sign.py | null | null | null | null | null | null | Python | 2026-05-04T02:02:49.579199 | # -*- encoding: utf-8 -*-
import math
import time
def rc4_encrypt(plaintext: str, key: str) -> str:
# 初始化状态数组
s = list(range(256))
# 使用密钥对状态数组进行置换
j = 0
for i in range(256):
j = (j + s[i] + ord(key[i % len(key)])) % 256
s[i], s[j] = s[j], s[i]
# 生成密钥流并加密
i = j = 0
res... |
ihmily/DouyinLiveRecorder | https://github.com/ihmily/DouyinLiveRecorder | null | null | null | null | 9,905 | null | null | mit | null | null | null | null | null | null | null | src/proxy.py | null | null | null | null | null | null | Python | 2026-05-04T02:02:50.150616 | import os
import sys
from enum import Enum, auto
from dataclasses import dataclass, field
from .utils import logger
class ProxyType(Enum):
HTTP = auto()
HTTPS = auto()
SOCKS = auto()
@dataclass(frozen=True)
class ProxyInfo:
ip: str = field(default="", repr=True)
port: str = field(default="", rep... |
ihmily/DouyinLiveRecorder | https://github.com/ihmily/DouyinLiveRecorder | null | null | null | null | 9,905 | null | null | mit | null | null | null | null | null | null | null | src/room.py | null | null | null | null | null | null | Python | 2026-05-04T02:02:50.156362 | # -*- encoding: utf-8 -*-
"""
Author: Hmily
GitHub:https://github.com/ihmily
Date: 2023-07-17 23:52:05
Update: 2025-02-04 04:57:00
Copyright (c) 2023 by Hmily, All Rights Reserved.
"""
import re
import urllib.parse
import execjs
import httpx
import urllib.request
from . import JS_SCRIPT_PATH, utils
no_proxy_handler =... |
ihmily/DouyinLiveRecorder | https://github.com/ihmily/DouyinLiveRecorder | null | null | null | null | 9,905 | null | null | mit | null | null | null | null | null | null | null | src/logger.py | null | null | null | null | null | null | Python | 2026-05-04T02:02:50.165200 | # -*- coding: utf-8 -*-
import os
import sys
from loguru import logger
logger.remove()
custom_format = "<green>{time:YYYY-MM-DD HH:mm:ss.SSS}</green> | <level>{level: <8}</level> - <level>{message}</level>"
logger.add(
sink=sys.stderr,
format=custom_format,
level="DEBUG",
colorize=True,
enqueue=... |
ihmily/DouyinLiveRecorder | https://github.com/ihmily/DouyinLiveRecorder | null | null | null | null | 9,905 | null | null | mit | null | null | null | null | null | null | null | src/utils.py | null | null | null | null | null | null | Python | 2026-05-04T02:02:50.165897 | # -*- coding: utf-8 -*-
import json
import os
import random
import shutil
import string
from pathlib import Path
import functools
import hashlib
import re
import traceback
from typing import Any
from urllib.parse import parse_qs, urlparse
from collections import OrderedDict
import execjs
from .logger import logger
impo... |
ihmily/DouyinLiveRecorder | https://github.com/ihmily/DouyinLiveRecorder | null | null | null | null | 9,905 | null | null | mit | null | null | null | null | null | null | null | src/stream.py | null | null | null | null | null | null | Python | 2026-05-04T02:02:50.195132 | # -*- encoding: utf-8 -*-
"""
Author: Hmily
GitHub: https://github.com/ihmily
Date: 2023-07-15 23:15:00
Update: 2025-02-06 02:28:00
Copyright (c) 2023-2025 by Hmily, All Rights Reserved.
Function: Get live stream data.
"""
import base64
import hashlib
import json
import time
import random
import re
from operator impor... |
drivendataorg/cookiecutter-data-science | https://github.com/drivendataorg/cookiecutter-data-science | null | null | null | null | 9,817 | null | null | mit | null | null | null | null | null | null | null | hooks/post_gen_project.py | null | null | null | null | null | null | Python | 2026-05-04T02:02:57.432031 | import shutil
from copy import copy
from pathlib import Path
# https://github.com/cookiecutter/cookiecutter/issues/824
# our workaround is to include these utility functions in the CCDS package
from ccds.hook_utils.custom_config import write_custom_config
from ccds.hook_utils.dependencies import (
basic,
fla... |
drivendataorg/cookiecutter-data-science | https://github.com/drivendataorg/cookiecutter-data-science | null | null | null | null | 9,817 | null | null | mit | null | null | null | null | null | null | null | docs/scripts/configuration-table.py | null | null | null | null | null | null | Python | 2026-05-04T02:02:57.433308 | import json
import re
from pathlib import Path
from ccds.hook_utils.dependencies import basic
PROJECT_ROOT = Path(__file__).parents[2]
def _table_row(items, delimiter="|"):
return f"| {' | '.join(items)} |"
def _table_header():
return [
_table_row(
(
"Choice",
... |
drivendataorg/cookiecutter-data-science | https://github.com/drivendataorg/cookiecutter-data-science | null | null | null | null | 9,817 | null | null | mit | null | null | null | null | null | null | null | ccds/hook_utils/custom_config.py | null | null | null | null | null | null | Python | 2026-05-04T02:02:57.434992 | from pathlib import Path
from shutil import copytree
from tempfile import TemporaryDirectory
from urllib.request import urlretrieve
from zipfile import ZipFile
from cookiecutter.vcs import clone
def write_custom_config(user_input_config):
if not user_input_config:
return
tmp = TemporaryDirectory()
... |
drivendataorg/cookiecutter-data-science | https://github.com/drivendataorg/cookiecutter-data-science | null | null | null | null | 9,817 | null | null | mit | null | null | null | null | null | null | null | hooks/pre_prompt.py | null | null | null | null | null | null | Python | 2026-05-04T02:02:57.444633 | import warnings
try:
from ccds import __version__
except ModuleNotFoundError:
__version__ = None # ccds is not installed
except ImportError:
__version__ = "2.0.0" # ccds is installed but version is 2.0.0
if __name__ == "__main__":
if __version__ is not None and __version__ < "2.0.1":
warning... |
drivendataorg/cookiecutter-data-science | https://github.com/drivendataorg/cookiecutter-data-science | null | null | null | null | 9,817 | null | null | mit | null | null | null | null | null | null | null | ccds/monkey_patch.py | null | null | null | null | null | null | Python | 2026-05-04T02:02:57.447823 | from collections import OrderedDict
from pathlib import Path
from cookiecutter.environment import StrictEnvironment
from cookiecutter.exceptions import UndefinedVariableInTemplate
from cookiecutter.generate import generate_context
from cookiecutter.prompt import (
prompt_choice_for_config,
read_user_choice,
... |
drivendataorg/cookiecutter-data-science | https://github.com/drivendataorg/cookiecutter-data-science | null | null | null | null | 9,817 | null | null | mit | null | null | null | null | null | null | null | ccds/__main__.py | null | null | null | null | null | null | Python | 2026-05-04T02:02:57.450238 | # Monkey-patch jinja to allow variables to not exist, which happens with sub-options
import jinja2
jinja2.StrictUndefined = jinja2.Undefined
# Monkey-patch cookiecutter to allow sub-items
from cookiecutter import prompt
from ccds.monkey_patch import prompt_for_config
prompt.prompt_for_config = prompt_for_config
... |
drivendataorg/cookiecutter-data-science | https://github.com/drivendataorg/cookiecutter-data-science | null | null | null | null | 9,817 | null | null | mit | null | null | null | null | null | null | null | docs/scripts/generate-termynal.py | null | null | null | null | null | null | Python | 2026-05-04T02:02:57.459531 | import json
import shutil
from pathlib import Path
import pexpect
from ansi2html import Ansi2HTMLConverter
CCDS_ROOT = Path(__file__).parents[2].resolve()
def execute_command_and_get_output(command, input_script):
input_script = iter(input_script)
child = pexpect.spawn(command, encoding="utf-8")
intera... |
drivendataorg/cookiecutter-data-science | https://github.com/drivendataorg/cookiecutter-data-science | null | null | null | null | 9,817 | null | null | mit | null | null | null | null | null | null | null | ccds/hook_utils/dependencies.py | null | null | null | null | null | null | Python | 2026-05-04T02:02:57.461054 | import tomlkit
packages = [
"pip",
"python-dotenv",
]
flake8_black_isort = [
"black",
"flake8",
"isort",
]
ruff = ["ruff"]
basic = [
"ipython",
"jupyterlab",
"matplotlib",
"notebook",
"numpy",
"pandas",
"scikit-learn",
]
scaffold = [
"typer",
"loguru",
"t... |
drivendataorg/cookiecutter-data-science | https://github.com/drivendataorg/cookiecutter-data-science | null | null | null | null | 9,817 | null | null | mit | null | null | null | null | null | null | null | tests/test_creation.py | null | null | null | null | null | null | Python | 2026-05-04T02:02:58.864684 | import json
import os
import sys
from pathlib import Path
from subprocess import PIPE, run
from conftest import bake_project
BASH_EXECUTABLE = os.getenv("BASH_EXECUTABLE", "bash")
def _decode_print_stdout_stderr(result):
"""Print command stdout and stderr to console to use when debugging failing tests
Norma... |
drivendataorg/cookiecutter-data-science | https://github.com/drivendataorg/cookiecutter-data-science | null | null | null | null | 9,817 | null | null | mit | null | null | null | null | null | null | null | {{ cookiecutter.repo_name }}/tests/unittest/test_data.py | null | null | null | null | null | null | Python | 2026-05-04T02:02:58.867894 | import unittest
class TestCodeIsTested(unittest.TestCase):
def test_code_is_tested(self):
self.assertTrue(False)
if __name__ == '__main__':
unittest.main()
|
drivendataorg/cookiecutter-data-science | https://github.com/drivendataorg/cookiecutter-data-science | null | null | null | null | 9,817 | null | null | mit | null | null | null | null | null | null | null | {{ cookiecutter.repo_name }}/{{ cookiecutter.module_name }}/dataset.py | null | null | null | null | null | null | Python | 2026-05-04T02:02:58.868960 | from pathlib import Path
from loguru import logger
from tqdm import tqdm
import typer
from {{ cookiecutter.module_name }}.config import PROCESSED_DATA_DIR, RAW_DATA_DIR
app = typer.Typer()
@app.command()
def main(
# ---- REPLACE DEFAULT PATHS AS APPROPRIATE ----
input_path: Path = RAW_DATA_DIR / "dataset.c... |
drivendataorg/cookiecutter-data-science | https://github.com/drivendataorg/cookiecutter-data-science | null | null | null | null | 9,817 | null | null | mit | null | null | null | null | null | null | null | tests/conftest.py | null | null | null | null | null | null | Python | 2026-05-04T02:02:58.869433 | import json
import shutil
import sys
import tempfile
from contextlib import contextmanager
from itertools import cycle, product
from pathlib import Path
import pytest
from ccds.__main__ import api_main
CCDS_ROOT = Path(__file__).parents[1].resolve()
default_args = {
"project_name": "my_test_project",
"repo... |
drivendataorg/cookiecutter-data-science | https://github.com/drivendataorg/cookiecutter-data-science | null | null | null | null | 9,817 | null | null | mit | null | null | null | null | null | null | null | {{ cookiecutter.repo_name }}/{{ cookiecutter.module_name }}/config.py | null | null | null | null | null | null | Python | 2026-05-04T02:02:58.870214 | from pathlib import Path
from dotenv import load_dotenv
from loguru import logger
# Load environment variables from .env file if it exists
load_dotenv()
# Paths
PROJ_ROOT = Path(__file__).resolve().parents[1]
logger.info(f"PROJ_ROOT path is: {PROJ_ROOT}")
DATA_DIR = PROJ_ROOT / "data"
RAW_DATA_DIR = DATA_DIR / "raw... |
drivendataorg/cookiecutter-data-science | https://github.com/drivendataorg/cookiecutter-data-science | null | null | null | null | 9,817 | null | null | mit | null | null | null | null | null | null | null | {{ cookiecutter.repo_name }}/{{ cookiecutter.module_name }}/features.py | null | null | null | null | null | null | Python | 2026-05-04T02:02:58.870734 | from pathlib import Path
from loguru import logger
from tqdm import tqdm
import typer
from {{ cookiecutter.module_name }}.config import PROCESSED_DATA_DIR
app = typer.Typer()
@app.command()
def main(
# ---- REPLACE DEFAULT PATHS AS APPROPRIATE ----
input_path: Path = PROCESSED_DATA_DIR / "dataset.csv",
... |
drivendataorg/cookiecutter-data-science | https://github.com/drivendataorg/cookiecutter-data-science | null | null | null | null | 9,817 | null | null | mit | null | null | null | null | null | null | null | {{ cookiecutter.repo_name }}/{{ cookiecutter.module_name }}/modeling/predict.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:00.397128 | from pathlib import Path
from loguru import logger
from tqdm import tqdm
import typer
from {{ cookiecutter.module_name }}.config import MODELS_DIR, PROCESSED_DATA_DIR
app = typer.Typer()
@app.command()
def main(
# ---- REPLACE DEFAULT PATHS AS APPROPRIATE ----
features_path: Path = PROCESSED_DATA_DIR / "te... |
drivendataorg/cookiecutter-data-science | https://github.com/drivendataorg/cookiecutter-data-science | null | null | null | null | 9,817 | null | null | mit | null | null | null | null | null | null | null | {{ cookiecutter.repo_name }}/{{ cookiecutter.module_name }}/plots.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:00.699617 | from pathlib import Path
from loguru import logger
from tqdm import tqdm
import typer
from {{ cookiecutter.module_name }}.config import FIGURES_DIR, PROCESSED_DATA_DIR
app = typer.Typer()
@app.command()
def main(
# ---- REPLACE DEFAULT PATHS AS APPROPRIATE ----
input_path: Path = PROCESSED_DATA_DIR / "data... |
drivendataorg/cookiecutter-data-science | https://github.com/drivendataorg/cookiecutter-data-science | null | null | null | null | 9,817 | null | null | mit | null | null | null | null | null | null | null | {{ cookiecutter.repo_name }}/{{ cookiecutter.module_name }}/modeling/train.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:00.813233 | from pathlib import Path
from loguru import logger
from tqdm import tqdm
import typer
from {{ cookiecutter.module_name }}.config import MODELS_DIR, PROCESSED_DATA_DIR
app = typer.Typer()
@app.command()
def main(
# ---- REPLACE DEFAULT PATHS AS APPROPRIATE ----
features_path: Path = PROCESSED_DATA_DIR / "fe... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | test/test_music_duration.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:03.200059 | import math
from xiaomusic.const import SUPPORT_MUSIC_TYPE
from xiaomusic.utils.file_utils import traverse_music_directory
from xiaomusic.utils.music_utils import get_local_music_duration
async def test_one_music(filename):
# 获取播放时长
duration = await get_local_music_duration(filename)
sec = math.ceil(dura... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | test/test_music_tags.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:03.202732 | import traceback
from xiaomusic.const import SUPPORT_MUSIC_TYPE
from xiaomusic.utils.file_utils import traverse_music_directory
from xiaomusic.utils.music_utils import extract_audio_metadata
# title 标题
# artist 艺术家
# album 影集
# year 年
# genre 性
# picture 图片
# lyrics 歌词
async def test_one_music(filename):
# 获取播放... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | plugins/code1.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:03.205566 | async def code1(arg1):
global log, xiaomusic
log.info(f"code1:{arg1}")
did = xiaomusic.get_cur_did()
await xiaomusic.do_tts(did, "你好,我是自定义的测试口令")
query = xiaomusic.command_handler.last_cmd.strip()
await xiaomusic.do_tts(did, f"你说的是: {query}")
|
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | test/test_difflib.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:03.208011 | import difflib
from xiaomusic.utils.text_utils import find_best_match, keyword_detection
if __name__ == "__main__":
user_input = "八年的爱"
s1 = "冰冰超人 - 八年的爱新版"
s2 = "冰冰超人 - 八年的爱"
r1 = difflib.SequenceMatcher(None, s1, user_input).ratio()
r2 = difflib.SequenceMatcher(None, s2, user_input).ratio()
... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | check_plugins.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:03.211450 | #!/usr/bin/env python3
"""
检查所有插件的加载状态
"""
import sys
sys.path.append(".")
from xiaomusic.config import Config
from xiaomusic.js_plugin_manager import JSPluginManager
def check_all_plugins():
print("=== 检查所有插件加载状态 ===\n")
config = Config()
config.verbose = True
class SimpleLogger:
def inf... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | test/test_remove_common_prefix.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:03.217256 | import re
def removepre(filename):
match = re.search(r"^[pP]?(\d+)\s+\d*(.+?)\.(.*$)", filename.strip())
new_filename = filename
if match:
num = match.group(1)
name = match.group(2).replace(".", " ").strip()
suffix = match.group(3)
# print(name)
# print(num)
... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | get_release.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:03.218743 | import json
import os
import requests
# 替换为你的 GitHub 仓库信息
GITHUB_OWNER = "hanxi"
GITHUB_REPO = "xiaomusic"
GITHUB_API_URL = f"https://api.github.com/repos/{GITHUB_OWNER}/{GITHUB_REPO}/releases"
def fetch_releases():
headers = {}
github_token = os.getenv("GITHUB_TOKEN")
if github_token:
headers["... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | plugins/httppost.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:03.219829 | import requests
target = "HTTP://192.168.1.10:58091/items/"
def httppost(data, url=target):
global log
# 发起请求,
with requests.post(
url, json=data, timeout=5
) as response: # 增加超时以避免长时间挂起
response.raise_for_status() # 如果响应不是200,引发HTTPError异常
log.info(f"httppost url:{url} data... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | plugins/httpget.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:03.226455 | import requests
def httpget(url):
global log
# 发起请求
response = requests.get(url, timeout=5) # 增加超时以避免长时间挂起
response.raise_for_status() # 如果响应不是200,引发HTTPError异常
log.info(f"httpget url:{url} response:{response.text}")
|
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | test/test_update.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:03.779164 | from xiaomusic.utils.system_utils import download_and_extract
if __name__ == "__main__":
import asyncio
url = "https://github.hanxi.cc/proxy/hanxi/xiaomusic/releases/download/main/app-amd64-lite.tar.gz"
target_directory = "./tmp/app"
asyncio.run(download_and_extract(url, target_directory))
|
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/analytics.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:03.838883 | import asyncio
import copy
import platform
import traceback
from datetime import datetime
import aiohttp
from ga4mp import GtagMP
from xiaomusic import __version__
MAX_PARAM_LENGTH = 100
class Analytics:
def __init__(self, log, config):
self.gtag = None
self.current_date = None
self.log... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | update-static-version.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:03.850797 | #!/usr/bin/env python3
import re
from pathlib import Path
def get_html_files(directory):
"""
获取指定目录下所有HTML文件的列表。
:param directory: 搜索HTML文件的目录。
:return: 搜索到的HTML文件的路径列表。
"""
return list(Path(directory).rglob("*.html"))
def update_html_version(html_files, version):
"""
更新HTML文件中所有以 ... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/api/dependencies.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:03.852110 | """依赖注入和认证相关功能"""
import hashlib
import secrets
import time # 🚀 新增:用于生成 7 天免密 Cookie 的过期时间(exp)
from typing import (
TYPE_CHECKING,
Annotated,
)
import jwt # 🚀 新增:用于生成和验证 JWT Token
from fastapi import (
Depends,
HTTPException,
Request,
Response, # 🚀 新增:引入 Response 用于写入 Coo... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/api/app.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:03.854405 | """FastAPI 应用实例和中间件配置"""
import asyncio
import os
from contextlib import asynccontextmanager
from typing import TYPE_CHECKING
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from starlette.middleware.gzip import GZipMiddleware
from xiaomusic import __version__
from xiaomusic.api.depend... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/api/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:03.855329 | """API 模块统一入口"""
from xiaomusic.api.app import (
HttpInit,
app,
)
__all__ = ["app", "HttpInit"]
|
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/api/models.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:03.863979 | """Pydantic 数据模型定义"""
from pydantic import BaseModel
class Did(BaseModel):
did: str
class DidVolume(BaseModel):
did: str
volume: int = 0
class DidCmd(BaseModel):
did: str
cmd: str
class MusicInfoObj(BaseModel):
musicname: str
title: str = ""
artist: str = ""
album: str = ""
... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/api/routers/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:03.891425 | """路由注册"""
from xiaomusic.api import websocket
from xiaomusic.api.routers import (
device,
file,
music,
playlist,
plugin,
system,
)
def register_routers(app):
"""注册所有路由到应用
Args:
app: FastAPI 应用实例
"""
# 注册各个路由模块
app.include_router(system.router, tags=["系统管理"])
... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/api/routers/device.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:04.404227 | """设备控制路由"""
import asyncio
import urllib.parse
from fastapi import (
APIRouter,
Depends,
)
from xiaomusic.api.dependencies import (
log,
verification,
xiaomusic,
)
from xiaomusic.api.models import (
Did,
DidCmd,
DidVolume,
)
router = APIRouter(dependencies=[Depends(verification)])
... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/api/routers/music.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:04.441557 | """音乐管理路由"""
import base64
import json
import urllib.parse
from fastapi import (
APIRouter,
Depends,
HTTPException,
Query,
Request,
)
from fastapi.responses import RedirectResponse
from xiaomusic.api.dependencies import (
log,
verification,
xiaomusic,
)
from xiaomusic.api.models impor... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/api/routers/playlist.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:04.473170 | """播放列表路由"""
from fastapi import (
APIRouter,
Depends,
)
from xiaomusic.api.dependencies import (
log,
verification,
xiaomusic,
)
from xiaomusic.api.models import (
DidPlayMusicList,
PlayListMusicObj,
PlayListObj,
PlayListUpdateObj,
)
router = APIRouter(dependencies=[Depends(verif... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/api/websocket.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:04.482024 | """WebSocket 相关功能"""
import asyncio
import json
import secrets
import time
import jwt
from fastapi import (
APIRouter,
Depends,
WebSocket,
WebSocketDisconnect,
)
from xiaomusic.api.dependencies import (
verification,
xiaomusic,
)
router = APIRouter()
# JWT 配置
# 使用固定的 secret 避免重启后 token 失效
#... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/command_handler.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:04.485005 | """命令处理模块
负责语音指令的解析、匹配和路由。
"""
import asyncio
import re
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from xiaomusic.xiaomusic import XiaoMusic
from xiaomusic.config import KEY_WORD_ARG_BEFORE_DICT
if TYPE_CHECKING:
pass
class CommandHandler:
"""命令处理器
负责解析用户的语音指令,匹配对应的命令,并路由到相应的处理方法。
"""... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/api/routers/system.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:04.489498 | """系统管理路由"""
import asyncio
import base64
import io
import json
import os
import shutil
import tempfile
from dataclasses import (
asdict,
)
from fastapi import (
APIRouter,
Depends,
HTTPException,
Request,
)
from fastapi.openapi.docs import (
get_redoc_html,
get_swagger_ui_html,
)
from fas... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/api/routers/plugin.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:04.491075 | """插件管理路由"""
import asyncio
import os
import aiofiles
from fastapi import (
APIRouter,
Depends,
File,
HTTPException,
Query,
Request,
UploadFile,
)
from xiaomusic.api.dependencies import (
verification,
xiaomusic,
)
router = APIRouter(dependencies=[Depends(verification)])
@route... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/cli.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:04.511028 | #!/usr/bin/env python3
import argparse
import json
import logging
import os
import signal
import sentry_sdk
from sentry_sdk.integrations.asyncio import AsyncioIntegration
from sentry_sdk.integrations.logging import (
LoggingIntegration,
ignore_logger,
)
LOGO = r"""
__ __ _ __ __ ... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/auth.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:04.514946 | """认证管理模块
本模块负责小米账号认证与会话管理,包括:
- 小米账号登录
- Cookie管理
- 会话维护
- 设备ID更新
"""
import json
import os
from aiohttp import ClientSession
from miservice import MiAccount, MiIOService, MiNAService
from xiaomusic.config import Device
from xiaomusic.const import COOKIE_TEMPLATE
from xiaomusic.utils.system_utils import (
get_... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/api/routers/file.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:04.553803 | import asyncio
import base64
import os
import shutil
import uuid
from urllib.parse import urlparse
import aiohttp
from fastapi import (
APIRouter,
Depends,
File,
Form,
HTTPException,
Request,
UploadFile,
)
from fastapi.responses import (
FileResponse,
RedirectResponse,
Response,... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/config.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:05.027349 | from __future__ import annotations
import argparse
import base64
import json
import os
from dataclasses import asdict, dataclass, field
from typing import get_type_hints
from xiaomusic.const import (
PLAY_TYPE_ALL,
PLAY_TYPE_ONE,
PLAY_TYPE_RND,
PLAY_TYPE_SEQ,
PLAY_TYPE_SIN,
)
from xiaomusic.utils.... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/config_manager.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:05.032173 | """配置管理模块
负责配置的加载、保存、更新和管理。
"""
import json
from dataclasses import asdict
class ConfigManager:
"""配置管理类
负责管理应用配置,包括:
- 从文件加载配置
- 保存配置到文件
- 更新配置
- 配置变更通知
"""
def __init__(self, config, log):
"""初始化配置管理器
Args:
config: 配置对象
log: 日志对象
"... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/device_manager.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:05.083307 | """设备管理模块
本模块负责小米音箱设备的管理,包括:
- 设备列表管理
- 设备分组管理
- 设备信息查询
"""
from typing import TYPE_CHECKING, Optional
from xiaomusic.device_player import XiaoMusicDevice
from xiaomusic.utils.text_utils import parse_str_to_dict
if TYPE_CHECKING:
from xiaomusic.xiaomusic import XiaoMusic
class DeviceManager:
"""设备管理器
... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/crontab.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:05.105429 | import json
from apscheduler.schedulers.asyncio import AsyncIOScheduler
from apscheduler.triggers.base import BaseTrigger
from apscheduler.triggers.cron import CronTrigger
from xiaomusic.holiday import is_off_day, is_working_day
from xiaomusic.utils.file_utils import clean_temp_dir
class CustomCronTrigger(BaseTrigg... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/const.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:05.106858 | SUPPORT_MUSIC_TYPE = [
".mp3",
".flac",
".wav",
".ape",
".ogg",
".m4a",
".wma",
]
LATEST_ASK_API = "https://userprofile.mina.mi.com/device_profile/v2/conversation?source=dialogu&hardware={hardware}×tamp={timestamp}&limit=2"
COOKIE_TEMPLATE = "deviceId={device_id}; serviceToken={service... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/device_player.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:05.108075 | """设备播放控制模块
负责单个设备的播放控制、下载管理、TTS处理等功能。
"""
import asyncio
import copy
import json
import os
import random
import time
from typing import TYPE_CHECKING
from miservice import miio_command
from xiaomusic.config import Device
if TYPE_CHECKING:
from xiaomusic.xiaomusic import XiaoMusic
from xiaomusic.const import (... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/conversation.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:05.127037 | """对话记录拉取模块
本模块负责从小爱音箱拉取对话记录,包括:
- 轮询最新对话记录
- 从小爱API获取对话
- 通过Mina服务获取对话
- 解析和验证对话记录
"""
import asyncio
import json
import time
from aiohttp import ClientSession, ClientTimeout
from xiaomusic.const import GET_ASK_BY_MINA, LATEST_ASK_API
class ConversationPoller:
"""对话记录轮询器
负责定期从小爱音箱拉取最新的对话记录,支持两种方式:
1... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/events.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:05.127704 | """事件系统模块
提供简单的事件发布-订阅机制,用于模块间的解耦通信。
"""
from collections.abc import Callable
# 事件类型常量
CONFIG_CHANGED = "config_changed"
DEVICE_CONFIG_CHANGED = "device_config_changed"
class EventBus:
"""事件总线类
实现简单的发布-订阅模式,支持事件的订阅、取消订阅和发布。
"""
def __init__(self):
"""初始化事件总线"""
self._subscribers: ... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/file_watcher.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:05.129541 | """文件监控模块
提供音乐目录的文件变化监控功能,支持防抖延迟处理。
"""
import os
from watchdog.events import (
FileCreatedEvent,
FileDeletedEvent,
FileMovedEvent,
FileSystemEventHandler,
)
from watchdog.observers import Observer
from xiaomusic.const import SUPPORT_MUSIC_TYPE
class XiaoMusicPathWatch(FileSystemEventHandler):
... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/holiday.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:05.162791 | import json
import logging
import os
from datetime import date
log = logging.getLogger(__package__)
# 用于存储已加载的年份数据
loaded_years = {}
def load_year_data(year):
"""加载指定年份的节假日数据"""
global loaded_years
if year in loaded_years:
return True
file_path = f"holiday/{year}.json"
if not os.path.e... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/js_adapter.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:05.624716 | #!/usr/bin/env python3
"""
JS 插件适配器
将 MusicFree JS 插件的数据格式转换为 xiaomusic 接口规范
"""
import logging
class JSAdapter:
"""JS 插件数据适配器"""
def __init__(self, xiaomusic):
self.xiaomusic = xiaomusic
self.log = logging.getLogger(__name__)
def format_search_results(
self, plugin_results: lis... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/music_library.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:05.633062 | """音乐库管理模块
负责音乐库的管理、播放列表操作、音乐搜索和标签管理。
"""
import asyncio
import base64
import copy
import json
import os
import random
import time
import urllib.parse
from collections import OrderedDict
from dataclasses import asdict
from urllib.parse import urlparse
from xiaomusic.const import SUPPORT_MUSIC_TYPE
from xiaomusic.eve... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/qrcode_login.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:05.692139 | import base64
import hashlib
import json
import locale
import os
import random
import time
from datetime import datetime, timedelta
from gzip import GzipFile
from io import BytesIO
from pathlib import Path
from urllib import parse
import requests
import tzlocal
from Crypto.Cipher import ARC4
from qrcode import QRCode
... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/plugin.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:05.693718 | import ast
import importlib
import inspect
import pkgutil
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from xiaomusic.xiaomusic import XiaoMusic
class PluginManager:
def __init__(self, xiaomusic: "XiaoMusic", plugin_dir="plugins"):
self.xiaomusic = xiaomusic
self.log = xiaomusic.log
... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/online_music.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:05.705888 | """在线音乐服务模块
负责MusicFree插件集成、在线音乐搜索和播放链接获取。
"""
import asyncio
import base64
import ipaddress
import json
import socket
from urllib.parse import urlparse
import aiohttp
from xiaomusic.const import PLAY_TYPE_ALL
def _build_keyword(song_name, artist):
"""
根据歌名和艺术家构建关键词
Args:
song_name: 歌名
... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/utils/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:05.734717 | #!/usr/bin/env python3
"""
工具函数模块
子模块分类:
- text_utils: 文本处理和搜索
- file_utils: 文件和目录操作
- music_utils: 音乐文件处理
- network_utils: 网络请求和下载
- system_utils: 系统操作和环境
"""
|
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/utils/network_utils.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:05.737148 | #!/usr/bin/env python3
"""网络请求和下载相关工具函数"""
import asyncio
import hashlib
import logging
import os
import time
from collections import OrderedDict
from pathlib import Path
from time import sleep
from urllib.parse import (
parse_qs,
urlparse,
)
import aiohttp
import edge_tts
log = logging.getLogger(__package__... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/utils/music_utils.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:05.746563 | #!/usr/bin/env python3
"""音乐文件处理相关工具函数"""
import asyncio
import base64
import hashlib
import io
import json
import logging
import mimetypes
import os
import re
import shutil
import struct
import subprocess
import tempfile
from dataclasses import (
asdict,
dataclass,
)
from urllib.parse import urlparse
import ... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/utils/openai_utils.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:05.773993 | #!/usr/bin/env python3
"""用于AI大模型调用的工具类"""
import asyncio
import json
import logging
from typing import Any
import aiohttp
log = logging.getLogger(__package__)
# 简化的音乐分析提示,专注于快速提取
MUSIC_ANALYSIS_PROMPT = """
你是一个音乐播放口令分析师,专门负责从用户指令中提取歌曲名和歌手名信息。
任务要求:
1. 识别用户指令中的歌曲名和歌手名
2. 按照JSON格式返回结果:{"name": "歌曲名", "artist": "歌手... |
hanxi/xiaomusic | https://github.com/hanxi/xiaomusic | null | null | null | null | 9,811 | null | null | mit | null | null | null | null | null | null | null | xiaomusic/utils/file_utils.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:05.803805 | #!/usr/bin/env python3
"""文件和目录操作相关工具函数"""
import logging
import os
import re
import shutil
log = logging.getLogger(__package__)
def _get_depth_path(root: str, directory: str, depth: int) -> str:
"""计算指定深度的路径"""
# 计算当前目录的深度
relative_path = root[len(directory) :].strip(os.sep)
path_parts = relative_p... |
microsoft/magentic-ui | https://github.com/microsoft/magentic-ui | null | null | null | null | 9,802 | null | null | mit | null | null | null | null | null | null | null | experiments/eval/prepare_for_submission.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:08.364767 | import os
import json
import argparse
from typing import Dict, Any, List
def load_questions_gaia(metadata_path: str) -> Dict[str, str]:
"""Load questions from a Gaia metadata JSONL file."""
questions: Dict[str, str] = {}
with open(metadata_path, "r") as f:
for line in f:
entry = json.l... |
microsoft/magentic-ui | https://github.com/microsoft/magentic-ui | null | null | null | null | 9,802 | null | null | mit | null | null | null | null | null | null | null | experiments/eval/plot_results.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:08.378185 | import matplotlib.pyplot as plt
import matplotlib.style as style
from matplotlib.ticker import PercentFormatter
import os
import argparse
import numpy as np
def create_accuracy_plot(save_path=None, save_dir=None):
"""
Parameters:
-----------
save_path : str, optional
Filename to save the figur... |
microsoft/magentic-ui | https://github.com/microsoft/magentic-ui | null | null | null | null | 9,802 | null | null | mit | null | null | null | null | null | null | null | experiments/endpoint_configs/test_client.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:08.379409 | import yaml
import asyncio
from autogen_core.models import ChatCompletionClient, UserMessage
async def test_chat_completion_client() -> None:
# Load the config file
print("Loading config...")
with open("config.yaml", "r") as f:
config = yaml.safe_load(f)
# Get the orchestrator client config
... |
microsoft/magentic-ui | https://github.com/microsoft/magentic-ui | null | null | null | null | 9,802 | null | null | mit | null | null | null | null | null | null | null | experiments/eval/sample_eval_systems.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:08.397813 | from autogen_core.models import ChatCompletionClient
from systems import MagenticUIAutonomousSystem
from systems.magentic_one_system import MagenticOneSystem
from magentic_ui.eval.benchmarks import WebVoyagerBenchmark
import os
def test_magentic_ui_system():
default_client_config = {
"provider": "OpenAICha... |
microsoft/magentic-ui | https://github.com/microsoft/magentic-ui | null | null | null | null | 9,802 | null | null | mit | null | null | null | null | null | null | null | experiments/eval/systems/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:08.399333 | from .magentic_ui_sim_user_system import MagenticUISimUserSystem
from .magentic_ui_system import MagenticUIAutonomousSystem
from .magentic_one_system import MagenticOneSystem
__all__ = ["MagenticUISimUserSystem", "MagenticUIAutonomousSystem", "MagententicOneSystem"] |
microsoft/magentic-ui | https://github.com/microsoft/magentic-ui | null | null | null | null | 9,802 | null | null | mit | null | null | null | null | null | null | null | experiments/eval/explore_results.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:08.400977 | import os
import json
import pandas as pd
import argparse
from typing import Dict, Any
from magentic_ui.eval.benchmarks.gaia.gaia import GaiaBenchmark
def get_run_results_df(
run_dir: str, data_dir: str, dataset_name: str = "Gaia"
) -> pd.DataFrame:
"""
Process a run directory and create a DataFrame conta... |
microsoft/magentic-ui | https://github.com/microsoft/magentic-ui | null | null | null | null | 9,802 | null | null | mit | null | null | null | null | null | null | null | experiments/eval/run.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:08.405557 | import json
import yaml
import argparse
import os
import datetime
from typing import Optional, Dict, Any, Callable
from magentic_ui.eval.core import run_evaluate_benchmark_func, evaluate_benchmark_func
from systems.magentic_ui_sim_user_system import MagenticUISimUserSystem
from magentic_ui.eval.systems import LLMSystem... |
microsoft/magentic-ui | https://github.com/microsoft/magentic-ui | null | null | null | null | 9,802 | null | null | mit | null | null | null | null | null | null | null | experiments/eval/analyze_sim_user.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:08.410375 | import asyncio
import logging
import pandas as pd
from typing import Dict, Any, Optional, Union
import argparse
import os
from datetime import datetime
from autogen_core.models import (
ChatCompletionClient,
UserMessage,
SystemMessage,
)
# Setup logging
logging.basicConfig(level=logging.INFO)
logger = log... |
microsoft/magentic-ui | https://github.com/microsoft/magentic-ui | null | null | null | null | 9,802 | null | null | mit | null | null | null | null | null | null | null | experiments/eval/systems/magentic_one_system.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:08.438406 | import asyncio
import json
import os
import aiofiles
import logging
import datetime
from PIL import Image
from pydantic import BaseModel
from typing import List, Dict, Any, Tuple
from autogen_core.models import ChatCompletionClient
from autogen_core import Image as AGImage
from autogen_agentchat.base import TaskResult,... |
microsoft/magentic-ui | https://github.com/microsoft/magentic-ui | null | null | null | null | 9,802 | null | null | mit | null | null | null | null | null | null | null | experiments/eval/systems/magentic_ui_sim_user_system.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:08.468461 | import asyncio
import json
import os
import aiofiles
import logging
import datetime
from pathlib import Path
from PIL import Image
from pydantic import BaseModel
from typing import List, Optional, Union, Dict, Any, Literal, Tuple
from autogen_core import ComponentModel
from autogen_core.models import ChatCompletionClie... |
microsoft/magentic-ui | https://github.com/microsoft/magentic-ui | null | null | null | null | 9,802 | null | null | mit | null | null | null | null | null | null | null | experiments/eval/systems/magentic_ui_system.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:09.241043 | import asyncio
import json
import os
import aiofiles
import logging
import datetime
from pathlib import Path
from PIL import Image
from pydantic import BaseModel
from typing import List, Dict, Any, Tuple
from autogen_core.models import ChatCompletionClient
from autogen_core import Image as AGImage
from autogen_agentcha... |
microsoft/magentic-ui | https://github.com/microsoft/magentic-ui | null | null | null | null | 9,802 | null | null | mit | null | null | null | null | null | null | null | samples/sample_file_surfer.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:09.354181 | import asyncio
import argparse
from autogen_agentchat.ui import Console
from autogen_ext.models.openai import OpenAIChatCompletionClient
from autogen_agentchat.conditions import TextMentionTermination
from magentic_ui.teams import RoundRobinGroupChat
from magentic_ui.agents import FileSurfer
from autogen_agentchat.agen... |
microsoft/magentic-ui | https://github.com/microsoft/magentic-ui | null | null | null | null | 9,802 | null | null | mit | null | null | null | null | null | null | null | samples/sample_coder.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:09.357663 | import asyncio
import argparse
from autogen_agentchat.ui import Console
from autogen_ext.models.openai import OpenAIChatCompletionClient
from autogen_agentchat.conditions import TextMentionTermination
from magentic_ui.agents import CoderAgent
from magentic_ui.teams import RoundRobinGroupChat
from autogen_agentchat.agen... |
microsoft/magentic-ui | https://github.com/microsoft/magentic-ui | null | null | null | null | 9,802 | null | null | mit | null | null | null | null | null | null | null | src/magentic_ui/agents/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:09.358261 | from .web_surfer import WebSurfer, WebSurferCUA, FaraWebSurfer
from ._coder import CoderAgent
from ._user_proxy import USER_PROXY_DESCRIPTION
from .file_surfer import FileSurfer
__all__ = [
"WebSurfer",
"WebSurferCUA",
"FaraWebSurfer",
"CoderAgent",
"USER_PROXY_DESCRIPTION",
"FileSurfer",
]
|
microsoft/magentic-ui | https://github.com/microsoft/magentic-ui | null | null | null | null | 9,802 | null | null | mit | null | null | null | null | null | null | null | src/magentic_ui/_docker.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:09.531518 | import logging
import os
import docker
from docker.errors import DockerException, ImageNotFound
BROWSER_IMAGE_ENV_VAR = "MAGENTIC_UI_BROWSER_IMAGE"
PYTHON_IMAGE_ENV_VAR = "MAGENTIC_UI_PYTHON_IMAGE"
DOCKER_REGISTRY = "ghcr.io/microsoft"
BROWSER_IMAGE = os.getenv(
BROWSER_IMAGE_ENV_VAR, f"{DOCKER_REGISTRY}/magenti... |
microsoft/magentic-ui | https://github.com/microsoft/magentic-ui | null | null | null | null | 9,802 | null | null | mit | null | null | null | null | null | null | null | src/magentic_ui/agents/_user_proxy.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:09.838283 | USER_PROXY_DESCRIPTION = """
The human user who gave the original task.
The human user has access to the same browser as the websurfer. However, they do not have the ability to write or execute code.
In case where the task requires further clarifying information, the user can be asked to clarify the task.
In case where... |
microsoft/magentic-ui | https://github.com/microsoft/magentic-ui | null | null | null | null | 9,802 | null | null | mit | null | null | null | null | null | null | null | src/magentic_ui/agents/_utils.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:09.950787 | import asyncio
import shlex
from typing import List, Tuple
from autogen_core import CancellationToken
from autogen_ext.code_executors.docker import DockerCommandLineCodeExecutor
async def exec_command_umask_patched(
self: DockerCommandLineCodeExecutor,
command: List[str],
cancellation_token: Cancellatio... |
microsoft/magentic-ui | https://github.com/microsoft/magentic-ui | null | null | null | null | 9,802 | null | null | mit | null | null | null | null | null | null | null | src/magentic_ui/agents/file_surfer/_browser_code_helpers.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:09.967623 | import inspect
from typing import Callable, List, Tuple
def _validate_path_impl() -> Callable[[str], None]:
"""The actual implementation of path validation"""
import os
def validate(path: str) -> None:
if path == ".":
print("true")
else:
print(os.path.exists(path))... |
microsoft/magentic-ui | https://github.com/microsoft/magentic-ui | null | null | null | null | 9,802 | null | null | mit | null | null | null | null | null | null | null | samples/sample_web_surfer.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:10.048414 | import argparse
import asyncio
from pathlib import Path
from autogen_agentchat.ui import Console
from autogen_ext.models.openai import OpenAIChatCompletionClient
from autogen_agentchat.conditions import TextMentionTermination
from autogen_agentchat.teams import RoundRobinGroupChat
from magentic_ui.agents import WebSurf... |
microsoft/magentic-ui | https://github.com/microsoft/magentic-ui | null | null | null | null | 9,802 | null | null | mit | null | null | null | null | null | null | null | src/magentic_ui/agents/_coder.py | null | null | null | null | null | null | Python | 2026-05-04T02:03:10.063525 | import asyncio
from pathlib import Path
import shutil
import tempfile
from typing import AsyncGenerator, List, Sequence, Optional
import re
from typing import Any, Mapping
import uuid
from loguru import logger
from datetime import datetime
from pydantic import Field
from autogen_core import CancellationToken, Component... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.