mirror of
https://github.com/amtoaer/bili-sync.git
synced 2026-05-08 01:02:49 +08:00
Compare commits
3 Commits
feat_video
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
791dd57f23 | ||
|
|
c4b227e26e | ||
|
|
744bb536b3 |
6
Cargo.lock
generated
6
Cargo.lock
generated
@@ -353,7 +353,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "bili_sync"
|
||||
version = "2.11.0"
|
||||
version = "2.11.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"arc-swap",
|
||||
@@ -413,7 +413,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "bili_sync_entity"
|
||||
version = "2.11.0"
|
||||
version = "2.11.1"
|
||||
dependencies = [
|
||||
"derivative",
|
||||
"either",
|
||||
@@ -425,7 +425,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "bili_sync_migration"
|
||||
version = "2.11.0"
|
||||
version = "2.11.1"
|
||||
dependencies = [
|
||||
"sea-orm-migration",
|
||||
]
|
||||
|
||||
@@ -4,7 +4,7 @@ default-members = ["crates/bili_sync"]
|
||||
resolver = "2"
|
||||
|
||||
[workspace.package]
|
||||
version = "2.11.0"
|
||||
version = "2.11.1"
|
||||
authors = ["amtoaer <amtoaer@gmail.com>"]
|
||||
license = "MIT"
|
||||
description = "由 Rust & Tokio 驱动的哔哩哔哩同步工具"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use bili_sync_entity::rule::Rule;
|
||||
use bili_sync_entity::*;
|
||||
use sea_orm::prelude::DateTime;
|
||||
use sea_orm::{DerivePartialModel, FromQueryResult};
|
||||
use serde::Serialize;
|
||||
|
||||
@@ -218,6 +219,7 @@ pub struct VideoSourceDetail {
|
||||
#[serde(default)]
|
||||
pub use_dynamic_api: Option<bool>,
|
||||
pub enabled: bool,
|
||||
pub latest_row_at: Option<DateTime>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
|
||||
@@ -9,7 +9,7 @@ use sea_orm::DatabaseConnection;
|
||||
use crate::api::wrapper::{ApiError, ApiResponse, ValidatedJson};
|
||||
use crate::bilibili::BiliClient;
|
||||
use crate::config::{Config, VersionedConfig};
|
||||
use crate::notifier::Notifier;
|
||||
use crate::notifier::{Message, Notifier};
|
||||
|
||||
pub(super) fn router() -> Router {
|
||||
Router::new()
|
||||
@@ -41,7 +41,10 @@ pub async fn ping_notifiers(
|
||||
*ignore_cache = Some(());
|
||||
}
|
||||
notifier
|
||||
.notify(bili_client.inner_client(), "This is a test notification from BiliSync.")
|
||||
.notify(bili_client.inner_client(), Message{
|
||||
message: "This is a test notification from BiliSync.".into(),
|
||||
image_url: Some("https://socialify.git.ci/amtoaer/bili-sync/image?description=1&font=KoHo&issues=1&language=1&logo=https%3A%2F%2Fs2.loli.net%2F2023%2F12%2F02%2F9EwT2yInOu1d3zm.png&name=1&owner=1&pattern=Signal&pulls=1&stargazers=1&theme=Light".to_owned()),
|
||||
})
|
||||
.await?;
|
||||
Ok(ApiResponse::ok(()))
|
||||
}
|
||||
|
||||
@@ -104,7 +104,8 @@ pub async fn get_video_sources_details(
|
||||
collection::Column::Name,
|
||||
collection::Column::Path,
|
||||
collection::Column::Rule,
|
||||
collection::Column::Enabled
|
||||
collection::Column::Enabled,
|
||||
collection::Column::LatestRowAt
|
||||
])
|
||||
.into_model::<VideoSourceDetail>()
|
||||
.all(&db),
|
||||
@@ -115,7 +116,8 @@ pub async fn get_video_sources_details(
|
||||
favorite::Column::Name,
|
||||
favorite::Column::Path,
|
||||
favorite::Column::Rule,
|
||||
favorite::Column::Enabled
|
||||
favorite::Column::Enabled,
|
||||
favorite::Column::LatestRowAt
|
||||
])
|
||||
.into_model::<VideoSourceDetail>()
|
||||
.all(&db),
|
||||
@@ -127,7 +129,8 @@ pub async fn get_video_sources_details(
|
||||
submission::Column::Path,
|
||||
submission::Column::Enabled,
|
||||
submission::Column::Rule,
|
||||
submission::Column::UseDynamicApi
|
||||
submission::Column::UseDynamicApi,
|
||||
submission::Column::LatestRowAt
|
||||
])
|
||||
.into_model::<VideoSourceDetail>()
|
||||
.all(&db),
|
||||
@@ -138,7 +141,8 @@ pub async fn get_video_sources_details(
|
||||
watch_later::Column::Id,
|
||||
watch_later::Column::Path,
|
||||
watch_later::Column::Enabled,
|
||||
watch_later::Column::Rule
|
||||
watch_later::Column::Rule,
|
||||
watch_later::Column::LatestRowAt
|
||||
])
|
||||
.into_model::<VideoSourceDetail>()
|
||||
.all(&db)
|
||||
@@ -152,6 +156,7 @@ pub async fn get_video_sources_details(
|
||||
rule_display: None,
|
||||
use_dynamic_api: None,
|
||||
enabled: false,
|
||||
latest_row_at: None,
|
||||
})
|
||||
}
|
||||
for sources in [&mut collections, &mut favorites, &mut submissions, &mut watch_later] {
|
||||
@@ -159,6 +164,7 @@ pub async fn get_video_sources_details(
|
||||
if let Some(rule) = &item.rule {
|
||||
item.rule_display = Some(rule.to_string());
|
||||
}
|
||||
item.latest_row_at = item.latest_row_at.filter(|dt| dt.and_utc().timestamp() != 0);
|
||||
});
|
||||
}
|
||||
Ok(ApiResponse::ok(VideoSourcesDetailsResponse {
|
||||
|
||||
@@ -18,6 +18,8 @@ pub enum Notifier {
|
||||
Telegram {
|
||||
bot_token: String,
|
||||
chat_id: String,
|
||||
#[serde(default)]
|
||||
skip_image: bool,
|
||||
},
|
||||
Webhook {
|
||||
url: String,
|
||||
@@ -60,8 +62,14 @@ impl Notifier {
|
||||
|
||||
async fn notify_internal<'a>(&self, client: &reqwest::Client, message: &Message<'a>) -> Result<()> {
|
||||
match self {
|
||||
Notifier::Telegram { bot_token, chat_id } => {
|
||||
if let Some(img_url) = &message.image_url {
|
||||
Notifier::Telegram {
|
||||
bot_token,
|
||||
chat_id,
|
||||
skip_image,
|
||||
} => {
|
||||
if let Some(img_url) = &message.image_url
|
||||
&& !*skip_image
|
||||
{
|
||||
let url = format!("https://api.telegram.org/bot{}/sendPhoto", bot_token);
|
||||
let params = [
|
||||
("chat_id", chat_id.as_str()),
|
||||
|
||||
@@ -21,7 +21,7 @@ export default defineConfig({
|
||||
nav: [
|
||||
{ text: "主页", link: "/" },
|
||||
{
|
||||
text: "v2.11.0",
|
||||
text: "v2.11.1",
|
||||
items: [
|
||||
{
|
||||
text: "程序更新",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# bili-sync 是什么?
|
||||
|
||||
> [!TIP]
|
||||
> 当前最新程序版本为 v2.11.0,文档将始终与最新程序版本保持一致。
|
||||
> 当前最新程序版本为 v2.11.1,文档将始终与最新程序版本保持一致。
|
||||
|
||||
bili-sync 是一款专为 NAS 用户编写的哔哩哔哩同步工具。
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "bili-sync-web",
|
||||
"version": "2.11.0",
|
||||
"version": "2.11.1",
|
||||
"devDependencies": {
|
||||
"@eslint/compat": "^1.4.1",
|
||||
"@eslint/js": "^9.39.2",
|
||||
|
||||
@@ -224,6 +224,7 @@ export interface VideoSourceDetail {
|
||||
ruleDisplay: string | null;
|
||||
useDynamicApi: boolean | null;
|
||||
enabled: boolean;
|
||||
latestRowAt: string | null;
|
||||
}
|
||||
|
||||
export interface VideoSourcesDetailsResponse {
|
||||
@@ -305,6 +306,7 @@ export interface TelegramNotifier {
|
||||
type: 'telegram';
|
||||
bot_token: string;
|
||||
chat_id: string;
|
||||
skip_image: boolean;
|
||||
}
|
||||
|
||||
export interface WebhookNotifier {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { Button } from '$lib/components/ui/button/index.js';
|
||||
import { Checkbox } from '$lib/components/ui/checkbox/index.js';
|
||||
import { Input } from '$lib/components/ui/input/index.js';
|
||||
import { Label } from '$lib/components/ui/label/index.js';
|
||||
import { toast } from 'svelte-sonner';
|
||||
@@ -12,6 +13,7 @@
|
||||
let type: 'telegram' | 'webhook' = 'telegram';
|
||||
let botToken = '';
|
||||
let chatId = '';
|
||||
let skipImage = false;
|
||||
let webhookUrl = '';
|
||||
let webhookTemplate = '';
|
||||
let webhookHeaders: { key: string; value: string }[] = [];
|
||||
@@ -23,6 +25,7 @@
|
||||
type = 'telegram';
|
||||
botToken = notifier.bot_token;
|
||||
chatId = notifier.chat_id;
|
||||
skipImage = notifier.skip_image;
|
||||
} else {
|
||||
type = 'webhook';
|
||||
webhookUrl = notifier.url;
|
||||
@@ -37,6 +40,7 @@
|
||||
type = 'telegram';
|
||||
botToken = '';
|
||||
chatId = '';
|
||||
skipImage = false;
|
||||
webhookUrl = '';
|
||||
webhookTemplate = '';
|
||||
webhookHeaders = [];
|
||||
@@ -57,7 +61,8 @@
|
||||
const newNotifier: Notifier = {
|
||||
type: 'telegram',
|
||||
bot_token: botToken.trim(),
|
||||
chat_id: chatId.trim()
|
||||
chat_id: chatId.trim(),
|
||||
skip_image: skipImage
|
||||
};
|
||||
onSave(newNotifier);
|
||||
} else {
|
||||
@@ -121,6 +126,10 @@
|
||||
<Input id="chat-id" placeholder="-1001234567890" bind:value={chatId} />
|
||||
<p class="text-muted-foreground text-xs">目标聊天室的 ID(个人用户、群组或频道)</p>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<Checkbox id="skip-image" bind:checked={skipImage} />
|
||||
<Label for="skip-image" class="text-sm font-normal">仅发送文字</Label>
|
||||
</div>
|
||||
{:else if type === 'webhook'}
|
||||
<div class="space-y-2">
|
||||
<Label for="webhook-url">Webhook URL</Label>
|
||||
|
||||
@@ -366,8 +366,9 @@
|
||||
<Table.Row>
|
||||
<Table.Head class="w-[20%]">名称</Table.Head>
|
||||
<Table.Head class="w-[30%]">下载路径</Table.Head>
|
||||
<Table.Head class="w-[15%]">最新视频时间</Table.Head>
|
||||
<Table.Head class="w-[15%]">过滤规则</Table.Head>
|
||||
<Table.Head class="w-[15%]">启用状态</Table.Head>
|
||||
<Table.Head class="w-[10%]">启用状态</Table.Head>
|
||||
<Table.Head class="w-[10%] text-right">操作</Table.Head>
|
||||
</Table.Row>
|
||||
</Table.Header>
|
||||
@@ -387,6 +388,17 @@
|
||||
</span>
|
||||
</div>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{#if source.latestRowAt}
|
||||
<Badge variant="secondary" class="flex w-fit items-center gap-1.5">
|
||||
{new Date(source.latestRowAt).toLocaleString('zh-CN')}
|
||||
</Badge>
|
||||
{:else}
|
||||
<Badge variant="secondary" class="flex w-fit items-center gap-1.5">
|
||||
-
|
||||
</Badge>
|
||||
{/if}
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{#if source.rule && source.rule.length > 0}
|
||||
<Tooltip.Root disableHoverableContent={true}>
|
||||
|
||||
Reference in New Issue
Block a user