Giter VIP home page Giter VIP logo

mildom_lib's Introduction

Downloads Downloads Downloads

これは何?

Python用Mildom APIの非公式ライブラリです。 開発途中です。
バグがあればGithubのissueをお願いします。
This is an unofficial api wrapper for Mildom. If you find any bugs, please report it on issues by English or Japanese.

対応状況

  • ProfileV2 API
  • PlayBack API (配信アーカイブ)
    • アーカイブの範囲取得
  • EnterStudio API (ライブ配信)

対応予定

  • async/await(非同期処理)

注意 - notice-

あくまでも非公式APIの非公式ラッパーです。開発が継続される保証はありません。
This is unofficial wrapper. There is no guarantee of continuous development.
※バージョン2.0でDiscord Bot等で使用可能なasyncモジュールを入れる予定です。

使い方 -how to use-

  • 下の例に沿って各種オブジェクトを生成して使用する。
    Use as the instruction below.
  • mildom.api_request から各種APIのレスポンスをJSON(dict)で受け取る。
    Use mildom.api_request to get API response as json(dict).

Userオブジェクト -ProfileV2 API-

情報を更新する時は、User.updateで情報を更新できます。
You can refresh the data with User.update.

import mildom
user_id = 12345678

# 8桁のIDを指定してユーザーオブジェクトを作成
user = mildom.User(user_id)

Examples:

# bool値でライブ中かどうかを取得
print(user.is_live)

# プロフィールの画像URLを取得
print(user.avatar_url)

# レベルを取得
print(user.level)
  • ライブ中かどうかだけを取得 -get only if it's streaming or not-
import mildom
user_id = 12345678

if mildom.is_live(user_id):
    print('now on live')

PlayBack(アーカイブ)オブジェクト -PlayBack API-

  • 複数のアーカイブをリストで取得 -get multiple playbacks as a list-
import mildom
user_id = 12345678
user = mildom.User(user_id)

# "limit" argument is optional.
playback_list: list = user.fetch_playback(limit=10)
  • 特定のアーカイブを取得 -fetch specific PlayBack-
import mildom
user_id = 12345678
user = mildom.User(user_id)

# index starts from 0.
playback = user.fetch_playback(index=10)

Examples:

# URLを取得
print(playback.url)
# タイトルを取得
print(playback.title)
# MP4のURLを取得
print(playback.source_url)

注意 -notice-

「最新から2番目のアーカイブを取得したい」といった場合にはindexを指定してください。
使用しているAPIが異なるため、レスポンスを高速化できます。
以下は指定範囲のアーカイブをランダムに取得するテストにおけるレスポンス時間の平均値です。

0~425
index api time: 0.045539161014556885
----------------------------------------------
legacy api time: 0.06734103298187255


200~425
index api time: 0.049199145197868346
----------------------------------------------
legacy api time: 0.08169150960445404

300~425
index api time: 0.049523269319534304
----------------------------------------------
legacy api time: 0.10116533222198486

LiveStream(ライブ配信)オブジェクト -EnterStudio API-

import mildom
live_stream = mildom.LiveStream(user_id)

# 配信状況を取得
print(live_stream.is_live)
# タイトルを取得
print(live_stream.title)
# m3u8形式でストリーミングのURLを取得(VLCなどで再生可能)
if live_stream.is_dvr_enabled:
    # 配信者がDVRを有効にしていないと取得不可
    video_stream_links = live_stream.dvr_videos

Search API

category引数に指定できるstr一覧
List of str that can be used as the category argument.
["user", "live_stream", "video", "playback", "recommended_live_stream", "clip_video"]

import mildom
search_result: mildom.SearchResult = mildom.search("query")
search_result_with_category_specified = mildom.search("query", category="user")

SearchResultオブジェクトの値一覧
List of variables of SearchResult object.

SearchResult.clip_videos: list
SearchResult.live_streams: list
SearchResult.recommended_live_streams: list
SearchResult.videos: list
SearchResult.users: list
SearchResult.playbacks: list

mildom_lib's People

Contributors

alpaca131 avatar

Stargazers

koko avatar  avatar  avatar Tom Farro avatar  avatar  avatar ddddddddddp avatar  avatar

Watchers

 avatar

mildom_lib's Issues

mildom.LiveStream get error 'realtime_playback_info'

It get error 'realtime_playback_info' at about 2022-02-17 21:59:05~21:59:07
Cause I use try-except so can't reproduce the error

def get_mildom_live(user_id):
live_stream = mildom.LiveStream(user_id)
return live_stream

user_id = 10882672
live = get_mildom_live(user_id) # I seems that the error is from this.
if live.is_live:
    print(f"{live.author_name} start live {live.title}") # Cause this didn't show when 21:59:07

dvr_info = response["realtime_playback_info"]

... other things spent about 3 seconds
kson組長(けいそん) didn't live now.
2022-02-17 21:58:54.219798 Total 4.621 seconds (wait 9 seconds)

... other things spent about 3 seconds
'realtime_playback_info'                                         << The error
2022-02-17 21:59:07.929586 Total 4.697 seconds (wait 9 seconds)

... other things spent about 3 seconds
kson組長(けいそん) start live ICARUSの世界で生き残れ!!【kson組長】 << started_since: 2022-02-17 21:59:04
Successfully posted in Discord, code 204.
2022-02-17 21:59:22.111924 Total 5.17 seconds (wait 9 seconds)

fetch_playback()でエラーが出る

PlayBack(アーカイブ)オブジェクト の
user.fetch_playback()で

body = response['body']
KeyError: 'body'
のエラーメッセージがでます。
調査お願いします。

素晴らしいライブラリーの公開ありがとう

Member only stream will lost body in mildom.LiveStream

Or only can use mildom.User(user_id) when live member only stream?
user_id = 10882672

Traceback (most recent call last):
  File "C:\Users\test01\Desktop\Twitter\new_twitcas.py", line 418, in <module>
    main()
  File "C:\Users\test01\Desktop\Twitter\new_twitcas.py", line 294, in main
    live = get_mildom_live(MILDOM_USERNAME[i]["Id"])
  File "C:\Users\test01\Desktop\Twitter\new_twitcas.py", line 98, in get_mildom_live
    live_stream_ = mildom.LiveStream(user_id)
  File "C:\Users\test01\AppData\Local\Programs\Python\Python39\lib\site-packages\mildom\__init__.py", line 87, in __init__
    response = api_request.live_info_request(user_id)["body"]
KeyError: 'body'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.