mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-03 05:34:23 -04:00
Format the code
This commit is contained in:
parent
e0ee364929
commit
9bb896e84b
@ -30,9 +30,9 @@ async def main():
|
|||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
if len(sys.argv) > 1 and sys.argv[1] == "-vv":
|
if len(sys.argv) > 1 and sys.argv[1] == "-vv":
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
logging.getLogger('watchfiles').setLevel(logging.WARNING)
|
logging.getLogger("watchfiles").setLevel(logging.WARNING)
|
||||||
|
|
||||||
jsons.set_serializer(lambda x, **_: format_date(x), Optional[date | int]) # type: ignore
|
jsons.set_serializer(lambda x, **_: format_date(x), Optional[date | int]) # type: ignore
|
||||||
async with ClientSession(
|
async with ClientSession(
|
||||||
json_serialize=lambda *args, **kwargs: jsons.dumps(
|
json_serialize=lambda *args, **kwargs: jsons.dumps(
|
||||||
*args, key_transformer=jsons.KEY_TRANSFORMER_CAMELCASE, **kwargs
|
*args, key_transformer=jsons.KEY_TRANSFORMER_CAMELCASE, **kwargs
|
||||||
|
@ -11,7 +11,7 @@ async def monitor(path: str, scanner: Scanner):
|
|||||||
if event == Change.added:
|
if event == Change.added:
|
||||||
await scanner.identify(file)
|
await scanner.identify(file)
|
||||||
elif event == Change.deleted:
|
elif event == Change.deleted:
|
||||||
await scanner.delete(file);
|
await scanner.delete(file)
|
||||||
elif event == Change.modified:
|
elif event == Change.modified:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
@ -21,7 +21,9 @@ class Scanner:
|
|||||||
self._api_key = api_key
|
self._api_key = api_key
|
||||||
self._url = os.environ.get("KYOO_URL", "http://back:5000")
|
self._url = os.environ.get("KYOO_URL", "http://back:5000")
|
||||||
try:
|
try:
|
||||||
self._ignore_pattern = re.compile(os.environ.get("LIBRARY_IGNORE_PATTERN", ""))
|
self._ignore_pattern = re.compile(
|
||||||
|
os.environ.get("LIBRARY_IGNORE_PATTERN", "")
|
||||||
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._ignore_pattern = re.compile("")
|
self._ignore_pattern = re.compile("")
|
||||||
logging.error(f"Invalid ignore pattern. Ignoring. Error: {e}")
|
logging.error(f"Invalid ignore pattern. Ignoring. Error: {e}")
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
use json::JsonValue;
|
use json::JsonValue;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use sha1::{Sha1, Digest};
|
use sha1::{Digest, Sha1};
|
||||||
use std::{
|
use std::{
|
||||||
fs,
|
fs, io,
|
||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
process::Stdio,
|
process::Stdio,
|
||||||
str::{self, FromStr}, io,
|
str::{self, FromStr},
|
||||||
};
|
};
|
||||||
use tokio::process::Command;
|
use tokio::process::Command;
|
||||||
use utoipa::ToSchema;
|
use utoipa::ToSchema;
|
||||||
@ -138,7 +138,6 @@ pub async fn identify(path: String) -> Result<MediaInfo, std::io::Error> {
|
|||||||
io::copy(&mut file, &mut hasher)?;
|
io::copy(&mut file, &mut hasher)?;
|
||||||
let sha = format!("{:x}", hasher.finalize());
|
let sha = format!("{:x}", hasher.finalize());
|
||||||
|
|
||||||
|
|
||||||
let general = output["media"]["track"]
|
let general = output["media"]["track"]
|
||||||
.members()
|
.members()
|
||||||
.find(|x| x["@type"] == "General")
|
.find(|x| x["@type"] == "General")
|
||||||
|
@ -11,7 +11,7 @@ use utoipa::OpenApi;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
audio::*,
|
audio::*,
|
||||||
identify::{identify, Chapter, MediaInfo, Video, Audio, Subtitle},
|
identify::{identify, Audio, Chapter, MediaInfo, Subtitle, Video},
|
||||||
state::Transcoder,
|
state::Transcoder,
|
||||||
video::*,
|
video::*,
|
||||||
};
|
};
|
||||||
@ -104,16 +104,13 @@ async fn identify_resource(
|
|||||||
.await
|
.await
|
||||||
.map_err(|_| ApiError::NotFound)?;
|
.map_err(|_| ApiError::NotFound)?;
|
||||||
|
|
||||||
identify(path)
|
identify(path).await.map(|info| Json(info)).map_err(|e| {
|
||||||
.await
|
eprintln!(
|
||||||
.map(|info| Json(info))
|
"Unhandled error occured while identifing the resource: {}",
|
||||||
.map_err(|e| {
|
e
|
||||||
eprintln!(
|
);
|
||||||
"Unhandled error occured while identifing the resource: {}",
|
ApiError::InternalError
|
||||||
e
|
})
|
||||||
);
|
|
||||||
ApiError::InternalError
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get attachments
|
/// Get attachments
|
||||||
|
Loading…
x
Reference in New Issue
Block a user