Format the code

This commit is contained in:
Zoe Roux 2023-08-01 00:01:10 +09:00
parent e0ee364929
commit 9bb896e84b
5 changed files with 17 additions and 19 deletions

View File

@ -30,9 +30,9 @@ async def main():
logging.basicConfig(level=logging.INFO)
if len(sys.argv) > 1 and sys.argv[1] == "-vv":
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(
json_serialize=lambda *args, **kwargs: jsons.dumps(
*args, key_transformer=jsons.KEY_TRANSFORMER_CAMELCASE, **kwargs

View File

@ -11,7 +11,7 @@ async def monitor(path: str, scanner: Scanner):
if event == Change.added:
await scanner.identify(file)
elif event == Change.deleted:
await scanner.delete(file);
await scanner.delete(file)
elif event == Change.modified:
pass
else:

View File

@ -21,7 +21,9 @@ class Scanner:
self._api_key = api_key
self._url = os.environ.get("KYOO_URL", "http://back:5000")
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:
self._ignore_pattern = re.compile("")
logging.error(f"Invalid ignore pattern. Ignoring. Error: {e}")

View File

@ -1,11 +1,11 @@
use json::JsonValue;
use serde::Serialize;
use sha1::{Sha1, Digest};
use sha1::{Digest, Sha1};
use std::{
fs,
fs, io,
path::PathBuf,
process::Stdio,
str::{self, FromStr}, io,
str::{self, FromStr},
};
use tokio::process::Command;
use utoipa::ToSchema;
@ -138,7 +138,6 @@ pub async fn identify(path: String) -> Result<MediaInfo, std::io::Error> {
io::copy(&mut file, &mut hasher)?;
let sha = format!("{:x}", hasher.finalize());
let general = output["media"]["track"]
.members()
.find(|x| x["@type"] == "General")

View File

@ -11,7 +11,7 @@ use utoipa::OpenApi;
use crate::{
audio::*,
identify::{identify, Chapter, MediaInfo, Video, Audio, Subtitle},
identify::{identify, Audio, Chapter, MediaInfo, Subtitle, Video},
state::Transcoder,
video::*,
};
@ -104,16 +104,13 @@ async fn identify_resource(
.await
.map_err(|_| ApiError::NotFound)?;
identify(path)
.await
.map(|info| Json(info))
.map_err(|e| {
eprintln!(
"Unhandled error occured while identifing the resource: {}",
e
);
ApiError::InternalError
})
identify(path).await.map(|info| Json(info)).map_err(|e| {
eprintln!(
"Unhandled error occured while identifing the resource: {}",
e
);
ApiError::InternalError
})
}
/// Get attachments