Bili You Documentation

repository·main·Indexed 25 days ago

https://github.com/lucinhu/bili_you

A third-party Bilibili client developed with Flutter. The project implements Bilibili features including video and anime playback, danmaku, search, and comment sections using official APIs. Documentation covers API base URLs, authentication endpoints, user information retrieval, video interaction (likes, coins, favorites), search functionality for videos and users, and live streaming playback.

Tokens
6K
Snippets
6
Records
64
Agent score
83%

What's inside Bili You

  1. Overview of Bili You

    main
    Bili You is a third-party Bilibili client built using the Flutter framework. It provides features such as video recommendations, video search, comment sections (including nested replies), related videos, hot searches, video and anime (bangumi) playback, danmaku (bullet comments), and user submissions.
  2. Replace launch screen images via Xcode

    main

    To replace the launch screen images using the Xcode graphical interface:

    1. Open the iOS project workspace by running open ios/Runner.xcworkspace in your terminal.
    2. In the Xcode Project Navigator, navigate to Runner/Assets.xcassets.
    3. Drag and drop your desired image files into the asset catalog to replace the existing launch screen assets.
    open ios/Runner.xcworkspace
  3. Initialize and run the Bili You application

    main

    The application entrypoint requires initializing several asynchronous services before running the Flutter app: BiliYouStorage, MediaKit, and WidgetsFlutterBinding. It also configures the system UI for an edge-to-edge immersive experience (transparent status and navigation bars) and locks the device orientation to portrait mode.

    void main() async {
      WidgetsFlutterBinding.ensureInitialized();
      await BiliYouStorage.ensureInitialized();
      MediaKit.ensureInitialized();
      runApp(const MyApp());
      
      SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
      SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
      SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
        systemNavigationBarColor: Colors.transparent,
        systemNavigationBarDividerColor: Colors.transparent,
        statusBarColor: Colors.transparent,
      ));
    }
  4. Retrieve User Information and Stats

    main

    Access user-related data using these endpoints:

    • userInfo: Get current user information ($apiBase/x/web-interface/nav).
    • userStat: Get user statistics such as dynamic count, following count, and follower count ($apiBase/x/web-interface/nav/stat).
    • followings: Get the user's following list ($apiBase/x/relation/followings).
    • followers: Get the user's follower list ($apiBase/x/relation/followers).
  5. Live Streaming Endpoints

    main

    Endpoints for Bilibili Live services:

    • userRecommendLive: Get live stream recommendations for the user.
    • livePlayUrl: Get live stream playback information.

    livePlayUrl Parameters:

    • room_id: The ID of the room (passed as cid).
    • qn: Quality setting (e.g., 80: Smooth, 150: HD, 400: Blu-ray, 10000: Original, 20000: 4K, 30000: Dolby).
  6. Search for users with `SearchApi.getSearchUsers()`

    main

    Searches for users based on a keyword. Returns a List<SearchUserItem>. Each item includes:

    • mid: User ID.
    • name: Username.
    • face: User avatar URL (prefixed with http:).
    • sign: User signature.
    • fansCount: Number of fans.
    • videoCount: Number of videos.
    • level: User level.
    • gender: User gender.
    • isUpper: Boolean indicating if they are an uploader.
    • isLive: Boolean indicating if they are currently live.
    • roomId: Live room ID if applicable.
    • officialVerify: Details about official verification status.
  7. Access BiliYouStorage boxes

    main

    Once initialized, you can access the following Hive boxes via the BiliYouStorage class to read or write data:

    • BiliYouStorage.user: Stores user-related information.
    • BiliYouStorage.networkData: Stores network-related data.
    • BiliYouStorage.settings: Stores application settings.
    • BiliYouStorage.history: Stores user history.
  8. Search for videos with `SearchApi.getSearchVideos()`

    main

    Searches for videos using a keyword, page number, and sort order. Returns a List<SearchVideoItem>. Each item includes:

    • coverUrl: The video cover image URL (prefixed with http:).
    • title: The video title (sanitized).
    • bvid: The Bilibili video ID.
    • upName: The author's name.
    • timeLength: Duration in seconds.
    • playNum: Play count.
    • pubDate: Publication date timestamp.
  9. Like or unlike a reply with addLike()

    main

    Use addLike to toggle a like/unlike action on a specific reply.

    Parameters:

    • type: The ReplyType of the comment section.
    • oid: The target object ID (e.g., video ID).
    • rpid: The specific reply ID.
    • likeOrUnlike: A boolean where true performs a like and false performs an unlike.

    Returns a ReplyAddLikeResult containing isSuccess and an error message.

  10. Configure MyApp for Bili You

    main

    The MyApp widget serves as the root of the application. It uses GetMaterialApp for state management and navigation. Key configuration features include:

    • HTTP Initialization: HttpUtils().init() is called during onInit.
    • Dynamic Theming: Uses DynamicColorBuilder to support system-level dynamic colors. The theme is determined by SettingsUtil.currentTheme. If set to BiliTheme.dynamic, it uses the device's dynamic color scheme.
    • Text Scaling: A custom builder applies a global textScaleFactor retrieved from SettingsStorageKeys.textScaleFactor via SettingsUtil.getValue.
    • Navigation: Uses BiliVideoPage.routeObserver for route monitoring.
    class MyApp extends StatelessWidget {
      const MyApp({super.key});
      @override
      Widget build(BuildContext context) {
        return DynamicColorBuilder(builder: ((lightDynamic, darkDynamic) {
          return GetMaterialApp(
              onInit: () async {
                await HttpUtils().init();
              },
              navigatorObservers: [BiliVideoPage.routeObserver],
              themeMode: SettingsUtil.currentThemeMode,
              theme: ThemeData(
                  colorScheme: SettingsUtil.currentTheme == BiliTheme.dynamic
                      ? lightDynamic ?? BiliTheme.dynamic.themeDataLight.colorScheme
                      : SettingsUtil.currentTheme.themeDataLight.colorScheme,
                  useMaterial3: true),
              darkTheme: ThemeData(
                  colorScheme: SettingsUtil.currentTheme == BiliTheme.dynamic
                      ? darkDynamic ?? BiliTheme.dynamic.themeDataDark.colorScheme
                      : SettingsUtil.currentTheme.themeDataDark.colorScheme,
                  useMaterial3: true),
              home: const MainPage(),
              builder: (context, child) => child == null
                  ? const SizedBox()
                  : MediaQuery(
                      data: MediaQuery.of(context).copyWith(
                          textScaleFactor: MediaQuery.of(context).textScaleFactor *
                              SettingsUtil.getValue(
                                  SettingsStorageKeys.textScaleFactor,
                                  defaultValue: 1.0)),
                      child: child));
        }));
      }
    }