Skip to content

Commit

Permalink
style: 尽量使用绝对路径引入包 (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
amtoaer committed Apr 26, 2024
1 parent 97aec74 commit 0958893
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/bilibili/credential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rsa::sha2::Sha256;
use rsa::{Oaep, RsaPublicKey};
use serde::{Deserialize, Serialize};

use super::error::BiliError;
use crate::bilibili::error::BiliError;
use crate::bilibili::Client;

#[derive(Default, Debug, Clone, Serialize, Deserialize)]
Expand Down
7 changes: 4 additions & 3 deletions src/bilibili/danmaku/ass_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use std::pin::Pin;
use anyhow::Result;
use tokio::io::{AsyncWrite, AsyncWriteExt, BufWriter};

use super::canvas::CanvasConfig;
use crate::bilibili::danmaku::{DrawEffect, Drawable};
use crate::bilibili::danmaku::canvas::CanvasConfig;
use crate::bilibili::danmaku::{DanmakuOption, DrawEffect, Drawable};

struct TimePoint {
t: f64,
Expand Down Expand Up @@ -38,7 +38,7 @@ impl fmt::Display for AssEffect {
}
}

impl super::DanmakuOption {
impl DanmakuOption {
pub fn ass_styles(&self) -> Vec<String> {
vec![
// Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, \
Expand Down Expand Up @@ -196,6 +196,7 @@ fn escape_text(text: &str) -> Cow<str> {
#[cfg(test)]
mod tests {
use super::*;

#[test]
fn time_point_fmt() {
assert_eq!(format!("{}", TimePoint { t: 0.0 }), "0:00:00.00");
Expand Down
2 changes: 1 addition & 1 deletion src/bilibili/danmaku/canvas/lane.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::CanvasConfig;
use crate::bilibili::danmaku::canvas::CanvasConfig;
use crate::bilibili::danmaku::Danmu;

pub enum Collision {
Expand Down
3 changes: 1 addition & 2 deletions src/bilibili/danmaku/canvas/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ use anyhow::Result;
use float_ord::FloatOrd;
use lane::Lane;

use super::{Danmu, Drawable};
use crate::bilibili::danmaku::canvas::lane::Collision;
use crate::bilibili::danmaku::danmu::DanmuType;
use crate::bilibili::danmaku::DrawEffect;
use crate::bilibili::danmaku::{Danmu, DrawEffect, Drawable};
use crate::bilibili::PageInfo;

#[derive(Debug, serde::Deserialize, serde::Serialize)]
Expand Down
3 changes: 2 additions & 1 deletion src/bilibili/danmaku/danmu.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//! 一个弹幕实例,但是没有位置信息
use anyhow::{bail, Result};

use super::canvas::CanvasConfig;
use crate::bilibili::danmaku::canvas::CanvasConfig;

#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum DanmuType {
#[default]
Expand Down
4 changes: 2 additions & 2 deletions src/bilibili/danmaku/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::path::PathBuf;
use anyhow::Result;
use tokio::fs::{self, File};

use super::canvas::CanvasConfig;
use super::{AssWriter, Danmu};
use crate::bilibili::danmaku::canvas::CanvasConfig;
use crate::bilibili::danmaku::{AssWriter, Danmu};
use crate::bilibili::PageInfo;
use crate::config::CONFIG;

Expand Down
3 changes: 1 addition & 2 deletions src/bilibili/video.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ use futures::TryStreamExt;
use prost::Message;
use reqwest::Method;

use super::danmaku::{DanmakuElem, DanmakuWriter};
use crate::bilibili::analyzer::PageAnalyzer;
use crate::bilibili::client::BiliClient;
use crate::bilibili::danmaku::DmSegMobileReply;
use crate::bilibili::danmaku::{DanmakuElem, DanmakuWriter, DmSegMobileReply};
use crate::bilibili::error::BiliError;

static MASK_CODE: u64 = 2251799813685247;
Expand Down
6 changes: 2 additions & 4 deletions src/core/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ use serde_json::json;
use tokio::fs;
use tokio::sync::{Mutex, Semaphore};

use super::status::{PageStatus, VideoStatus};
use super::utils::{
unhandled_videos_pages, update_pages_model, update_videos_model, ModelWrapper, NFOMode, NFOSerializer, TEMPLATE,
};
use crate::bilibili::{BestStream, BiliClient, BiliError, Dimension, FavoriteList, PageInfo, Video};
use crate::config::CONFIG;
use crate::core::status::{PageStatus, VideoStatus};
use crate::core::utils::{
create_video_pages, create_videos, exist_labels, filter_unfilled_videos, handle_favorite_info, total_video_count,
unhandled_videos_pages, update_pages_model, update_videos_model, ModelWrapper, NFOMode, NFOSerializer, TEMPLATE,
};
use crate::downloader::Downloader;
use crate::error::{DownloadAbortError, ProcessPageError};
Expand Down
2 changes: 1 addition & 1 deletion src/core/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ use sea_orm::QuerySelect;
use serde_json::json;
use tokio::io::AsyncWriteExt;

use super::status::Status;
use crate::bilibili::{FavoriteListInfo, PageInfo, VideoInfo};
use crate::config::CONFIG;
use crate::core::status::Status;

pub static TEMPLATE: Lazy<handlebars::Handlebars> = Lazy::new(|| {
let mut handlebars = handlebars::Handlebars::new();
Expand Down
8 changes: 4 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ mod error;
use env_logger::Env;
use once_cell::sync::Lazy;

use self::bilibili::BiliClient;
use self::config::CONFIG;
use self::core::command::{process_favorite_list, SCAN_ONLY};
use self::database::{database_connection, migrate_database};
use crate::bilibili::BiliClient;
use crate::config::CONFIG;
use crate::core::command::{process_favorite_list, SCAN_ONLY};
use crate::database::{database_connection, migrate_database};

#[tokio::main]
async fn main() -> ! {
Expand Down

0 comments on commit 0958893

Please sign in to comment.