Skip to content

Commit

Permalink
Organize platform source files into their respective directories
Browse files Browse the repository at this point in the history
  • Loading branch information
SpriteOvO committed Apr 6, 2024
1 parent 7983834 commit 1906cda
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 21 deletions.
File renamed without changes.
19 changes: 7 additions & 12 deletions src/source/bilibili_live.rs → src/source/bilibili/live.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,18 @@ use anyhow::{anyhow, bail};
use serde::Deserialize;
use serde_json::{self as json, json};

use super::{
FetcherTrait, LiveStatus, SourcePlatformName, Status, StatusKind, StatusSource,
StatusSourceUser,
use super::Response;
use crate::{
config::SourcePlatformBilibiliLive,
source::{
FetcherTrait, LiveStatus, SourcePlatformName, Status, StatusKind, StatusSource,
StatusSourceUser,
},
};
use crate::config::SourcePlatformBilibiliLive;

const BILIBILI_LIVE_API: &str =
"https://api.live.bilibili.com/room/v1/Room/get_status_info_by_uids";

#[derive(Deserialize)]
pub(crate) struct Response<T> {
pub(crate) code: i32,
#[allow(dead_code)]
pub(crate) message: String,
pub(crate) data: Option<T>,
}

#[derive(Deserialize)]
struct ResponseDataRoom {
title: String,
Expand Down
12 changes: 12 additions & 0 deletions src/source/bilibili/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
pub(super) mod live;
pub(super) mod space;

use serde::Deserialize;

#[derive(Deserialize)]
struct Response<T> {
pub(crate) code: i32,
#[allow(dead_code)]
pub(crate) message: String,
pub(crate) data: Option<T>,
}
10 changes: 5 additions & 5 deletions src/source/bilibili_space.rs → src/source/bilibili/space.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ use spdlog::prelude::*;
use tap::prelude::*;
use tokio::sync::{Mutex, OnceCell};

use super::{
bilibili_live::Response, FetcherTrait, Notification, NotificationKind, Post, PostAttachment,
PostAttachmentImage, Posts, SourcePlatformName, Status, StatusKind, StatusSource, User,
};
use super::Response;
use crate::{
config::SourcePlatformBilibiliSpace,
source::{PostsRef, RepostFrom},
source::{
FetcherTrait, Notification, NotificationKind, Post, PostAttachment, PostAttachmentImage,
Posts, PostsRef, RepostFrom, SourcePlatformName, Status, StatusKind, StatusSource, User,
},
};

mod data {
Expand Down
7 changes: 3 additions & 4 deletions src/source/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
mod bilibili_live;
mod bilibili_space;
mod bilibili;
mod twitter;

use std::{
Expand Down Expand Up @@ -241,8 +240,8 @@ pub trait FetcherTrait: Display + Send + Sync {

pub fn fetcher(platform: &SourcePlatform) -> Box<dyn FetcherTrait> {
match platform {
SourcePlatform::BilibiliLive(p) => Box::new(bilibili_live::Fetcher::new(p.clone())),
SourcePlatform::BilibiliSpace(p) => Box::new(bilibili_space::Fetcher::new(p.clone())),
SourcePlatform::BilibiliLive(p) => Box::new(bilibili::live::Fetcher::new(p.clone())),
SourcePlatform::BilibiliSpace(p) => Box::new(bilibili::space::Fetcher::new(p.clone())),
SourcePlatform::Twitter(p) => Box::new(twitter::Fetcher::new(p.clone())),
}
}
Expand Down
File renamed without changes.

0 comments on commit 1906cda

Please sign in to comment.