commit
a56c99a45a
|
@ -1,17 +0,0 @@
|
|||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": ".."
|
||||
},
|
||||
{
|
||||
"path": "../parser"
|
||||
},
|
||||
{
|
||||
"path": "../md-parser"
|
||||
},
|
||||
{
|
||||
"path": "../api-gen"
|
||||
},
|
||||
],
|
||||
"settings": {}
|
||||
}
|
45
.github/workflows/ci.yml
vendored
Normal file
45
.github/workflows/ci.yml
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
on:
|
||||
- push
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install latest stable
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
components: rustfmt, clippy
|
||||
|
||||
- name: Run cargo check
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: check
|
||||
|
||||
- name: Run cargo clippy
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: clippy
|
||||
args: -- -D warnings
|
||||
test:
|
||||
runs-on: ubuntu-22.04
|
||||
services:
|
||||
# Needed for tests to pass
|
||||
qbittorrent:
|
||||
image: linuxserver/qbittorrent:4.4.3
|
||||
ports:
|
||||
- 8080:8080
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install latest stable
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
components: rustfmt, clippy
|
||||
|
||||
- name: Run tests
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: --workspace
|
||||
|
65
Cargo.lock
generated
65
Cargo.lock
generated
|
@ -11,19 +11,29 @@ dependencies = [
|
|||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.58"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bb07d2053ccdbe10e2af2995a2f116c1330396493dc1269f6a91d0ae82e19704"
|
||||
|
||||
[[package]]
|
||||
name = "api-gen"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"case",
|
||||
"parser",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"regex",
|
||||
"reqwest",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"syn",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"trybuild",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -90,6 +100,12 @@ version = "0.8.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
|
||||
|
||||
[[package]]
|
||||
name = "dissimilar"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8c97b9233581d84b8e1e689cdd3a47b6f69770084fc246e86a7f78b0d9c1d4a5"
|
||||
|
||||
[[package]]
|
||||
name = "encoding_rs"
|
||||
version = "0.8.31"
|
||||
|
@ -178,6 +194,12 @@ dependencies = [
|
|||
"pin-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glob"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
|
||||
|
||||
[[package]]
|
||||
name = "h2"
|
||||
version = "0.3.13"
|
||||
|
@ -791,6 +813,15 @@ dependencies = [
|
|||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.31"
|
||||
|
@ -881,6 +912,15 @@ dependencies = [
|
|||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.5.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tower-service"
|
||||
version = "0.3.2"
|
||||
|
@ -913,6 +953,22 @@ version = "0.2.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642"
|
||||
|
||||
[[package]]
|
||||
name = "trybuild"
|
||||
version = "1.0.63"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "764b9e244b482a9b81bde596aa37aa6f1347bf8007adab25e59f901b32b4e0a0"
|
||||
dependencies = [
|
||||
"dissimilar",
|
||||
"glob",
|
||||
"once_cell",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"termcolor",
|
||||
"toml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicase"
|
||||
version = "2.6.0"
|
||||
|
@ -1075,6 +1131,15 @@ version = "0.4.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
|
|
|
@ -10,7 +10,14 @@ path = "src/lib.rs"
|
|||
[dependencies]
|
||||
reqwest = { version = "0.11.11", features = ["json", "multipart"] }
|
||||
tokio = { version = "1.19.2", features = ["full"] }
|
||||
api-gen = { path = "./api-gen" }
|
||||
api-gen = { path = "./api-gen", version = "*" }
|
||||
serde = { version = "1.0.138", features = ["derive"] }
|
||||
serde_json = "1.0.82"
|
||||
thiserror = "1.0.31"
|
||||
|
||||
[workspace]
|
||||
members = [
|
||||
"api-gen",
|
||||
"parser",
|
||||
"md-parser",
|
||||
]
|
||||
|
|
1187
api-gen/Cargo.lock
generated
1187
api-gen/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,6 @@
|
|||
use anyhow::Result;
|
||||
use api_gen::QBittorrentApiGen;
|
||||
use tokio::time::{sleep, Duration};
|
||||
|
||||
const USERNAME: &str = "admin";
|
||||
const PASSWORD: &str = "adminadmin";
|
||||
|
@ -16,9 +17,19 @@ async fn main() -> Result<()> {
|
|||
const TORRENT_URL: &str = "http://www.legittorrents.info/download.php?id=5cc013e801095be61d768e609e3039da58616fd0&f=Oddepoxy%20-%20Oddepoxy%20(2013)%20[OGG%20320%20CBR].torrent";
|
||||
let _ = api.torrent_management().add(TORRENT_URL).send().await?;
|
||||
|
||||
let info = api.torrent_management().info().send().await?;
|
||||
let first = &info[0];
|
||||
assert_ne!(first.state, api_impl::TorrentManagementInfoState::Unknown);
|
||||
let mut tries = 5;
|
||||
while tries > 0 {
|
||||
let info = api.torrent_management().info().send().await?;
|
||||
if let Some(first) = &info.get(0) {
|
||||
// just check that something is there
|
||||
assert_ne!(first.added_on, 0);
|
||||
return Ok(());
|
||||
} else {
|
||||
tries -= 1;
|
||||
println!("torrent not found, sleeping for 1 second");
|
||||
sleep(Duration::from_secs(1)).await;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
panic!("Failed to find torrent!");
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use anyhow::Result;
|
||||
use api_gen::QBittorrentApiGen;
|
||||
use tokio::time::{sleep, Duration};
|
||||
|
||||
const USERNAME: &str = "admin";
|
||||
const PASSWORD: &str = "adminadmin";
|
||||
|
@ -16,10 +17,19 @@ async fn main() -> Result<()> {
|
|||
const TORRENT_URL: &str = "http://www.legittorrents.info/download.php?id=5cc013e801095be61d768e609e3039da58616fd0&f=Oddepoxy%20-%20Oddepoxy%20(2013)%20[OGG%20320%20CBR].torrent";
|
||||
let _ = api.torrent_management().add(TORRENT_URL).send().await?;
|
||||
|
||||
let info = api.torrent_management().info().send().await?;
|
||||
let first = &info[0];
|
||||
// just check that something is there
|
||||
assert_ne!(first.added_on, 0);
|
||||
let mut tries = 5;
|
||||
while tries > 0 {
|
||||
let info = api.torrent_management().info().send().await?;
|
||||
if let Some(first) = &info.get(0) {
|
||||
// just check that something is there
|
||||
assert_ne!(first.added_on, 0);
|
||||
return Ok(());
|
||||
} else {
|
||||
tries -= 1;
|
||||
println!("torrent not found, sleeping for 1 second");
|
||||
sleep(Duration::from_secs(1)).await;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
panic!("Failed to find torrent!");
|
||||
}
|
||||
|
|
7
md-parser/Cargo.lock
generated
7
md-parser/Cargo.lock
generated
|
@ -1,7 +0,0 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "md-parser"
|
||||
version = "0.1.0"
|
|
@ -16,9 +16,7 @@ pub struct Table {
|
|||
|
||||
impl Table {
|
||||
fn raw(&self) -> String {
|
||||
let mut output = Vec::new();
|
||||
output.push(self.header.raw.clone());
|
||||
output.push(self.split.clone());
|
||||
let mut output = vec![self.header.raw.clone(), self.split.clone()];
|
||||
for row in self.rows.clone() {
|
||||
output.push(row.raw);
|
||||
}
|
||||
|
@ -84,7 +82,7 @@ impl MdToken {
|
|||
fn from(content: &str) -> Vec<MdToken> {
|
||||
let mut output = Vec::new();
|
||||
|
||||
let mut iter = content.lines().into_iter();
|
||||
let mut iter = content.lines();
|
||||
while let Some(line) = iter.next() {
|
||||
// assume this is a table
|
||||
if line.contains('|') {
|
||||
|
|
54
parser/Cargo.lock
generated
54
parser/Cargo.lock
generated
|
@ -1,54 +0,0 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "0.7.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "case"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fd6c0e7b807d60291f42f33f58480c0bfafe28ed08286446f45e463728cf9c1c"
|
||||
|
||||
[[package]]
|
||||
name = "md-parser"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
||||
|
||||
[[package]]
|
||||
name = "parser"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"case",
|
||||
"md-parser",
|
||||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.6.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244"
|
Loading…
Reference in New Issue
Block a user