Skip to content

Commit

Permalink
Merge pull request #65 from nandyalu/dev
Browse files Browse the repository at this point in the history
Changes for v0.2.3-beta release
  • Loading branch information
nandyalu authored Dec 4, 2024
2 parents ab55f6e + 88dc27e commit c007f4f
Show file tree
Hide file tree
Showing 92 changed files with 7,476 additions and 3,995 deletions.
6 changes: 3 additions & 3 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ FROM mcr.microsoft.com/devcontainers/python:1-3.12-bullseye
RUN apt-get update && apt-get install -y curl xz-utils tzdata git

# Install Node.js
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - &&\
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - &&\
apt-get install -y nodejs

# Install specific version of npm
RUN npm install -g npm@10.8.3
RUN npm install -g npm@10.9.1

# Install specific version of Angular CLI
RUN npm install -g @angular/cli@17.3.6
RUN npm install -g @angular/cli@19.0.1

# Install Python Packages
COPY dev-requirements.txt .
Expand Down
16 changes: 8 additions & 8 deletions .devcontainer/dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# DevContainer requirements
# Docs
mkdocs-material==9.5.32
mkdocs-material==9.5.47

# Backend
aiohttp==3.10.5
aiohttp==3.11.9
aiofiles==24.1.0
alembic==1.13.2
apscheduler==3.10.4
alembic==1.14.0
apscheduler==3.11.0
async-lru==2.0.4
fastapi[standard]==0.115.0
bcrypt==4.2.0
pillow==10.4.0
fastapi[standard]==0.115.6
bcrypt==4.2.1
pillow==11.0.0
sqlmodel==0.0.22
yt-dlp==2024.8.6
yt-dlp[default]==2024.12.03

# Testing
aioresponses==0.7.6
Expand Down
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"KevinRose.vsc-python-indent",
"qwtel.sqlite-viewer",
"oderwat.indent-rainbow",
"redhat.vscode-yaml"
"redhat.vscode-yaml",
"GitHub.copilot-chat"
]
}
},
Expand Down
8 changes: 8 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ The commit message:
- is clear about what part of the code is affected -- often by prefixing with the name of the subsystem and a colon, like "express: ..." or "docs: ...".
- is a complete sentence, ending with a period.

### Commit Signing Error

If you get an error like `gpg: signing failed: Inappropriate ioctl for device` while committing, you can test signing by running the following command:

```bash
echo "This is a test message for GPG signing." | gpg --clearsign
```

## License

By contributing, you agree that your contributions will be licensed under its [GPL-3.0 license](https://github.com/nandyalu/trailarr?tab=GPL-3.0-1-ov-file).
20 changes: 10 additions & 10 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,29 @@ assignees: ''
---

**Describe the bug**
A clear and concise description of what the bug is.
<!-- A clear and concise description of what the bug is. -->

**Steps To Reproduce**
Steps to reproduce the behavior:
<!-- Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
4. See error -->

**Actual behavior**
A clear and concise description of what is happening.
<!-- A clear and concise description of what is happening. -->

**Expected behavior**
A clear and concise description of what you expected to happen.
<!-- A clear and concise description of what you expected to happen. -->

**Screenshots**
If applicable, add screenshots to help explain your problem.
<!-- If applicable, add screenshots to help explain your problem. -->

**App Information (please complete the following information):**
- Base OS: [e.g. Ubuntu]
- Base OS: [e.g. Ubuntu]
- Architecture: (run `dpkg --print-architecture` to find out). [e.g. arm64, amd64]
- Version [e.g. 22.04]
- Browser (if related to webpage) [e.g. chrome 127.0.6533.89 (Official Build) (64-bit)]
- Version [e.g. 22.04]
- Browser (if related to webpage) [e.g. chrome 127.0.6533.89 (Official Build) (64-bit)]

**Additional context**
Add any other context about the problem here.
<!-- Add any other context about the problem here. -->
8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ assignees: ''
---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->

**Describe the solution you'd like**
A clear and concise description of what you want to happen.
<!-- A clear and concise description of what you want to happen. -->

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
<!-- A clear and concise description of any alternative solutions or features you've considered. -->

**Additional context**
Add any other context or screenshots about the feature request here.
<!-- Add any other context or screenshots about the feature request here. -->
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/question-help-wanted.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ assignees: ''
- [ ] I already checked existing Issues to see if this is reported

**Describe your question**
A clear and concise description of what you need help with. Ex. I'm having difficulty in setting up volume mapping [...]
<!-- A clear and concise description of what you need help with. Ex. I'm having difficulty in setting up volume mapping [...] -->

**Additional context**
Add any other context or screenshots about the request here.
<!-- Add any other context or screenshots about the request here. -->
34 changes: 30 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,33 @@

version: 2
updates:
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: weekly
# Maintain dependencies for pip - devcontainer
- package-ecosystem: "pip"
directory: "/.devcontainer"
schedule:
interval: weekly
target-branch: "dev"
open-pull-requests-limit: 3 # Limit the number of open PRs
reviewers: # Add reviewers
- "nandyalu"
# Maintain dependencies for pip - backend
- package-ecosystem: "pip"
directory: "/backend"
schedule:
interval: weekly
target-branch: "dev"
open-pull-requests-limit: 3 # Limit the number of open PRs
reviewers: # Add reviewers
- "nandyalu"
# Maintain dependencies for npm - frontend (Angular and rxjs only)
- package-ecosystem: "npm"
directory: "/frontend"
schedule:
interval: weekly
target-branch: "dev"
open-pull-requests-limit: 3 # Limit the number of open PRs
reviewers: # Add reviewers
- "nandyalu"
allow:
- dependency-name: "@angular/*"
- dependency-name: "rxjs"
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

[![Python](https://img.shields.io/badge/python-3.12-3670A0?style=flat&logo=python)](https://www.python.org/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![FastAPI](https://img.shields.io/badge/FastAPI-0.115.0-009688.svg?style=flat&logo=FastAPI)](https://fastapi.tiangolo.com)
[![Angular](https://img.shields.io/badge/angular-17.3.6-%23DD0031.svg?style=flat&logo=angular)](https://angular.dev/)
[![FastAPI](https://img.shields.io/badge/FastAPI-0.115.6-009688.svg?style=flat&logo=FastAPI)](https://fastapi.tiangolo.com)
[![Angular](https://img.shields.io/badge/angular-19.0.1-%23DD0031.svg?style=flat&logo=angular)](https://angular.dev/)
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://github.com/nandyalu/trailarr)

[![Open in Dev Containers](https://img.shields.io/static/v1?label=Dev%20Container&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/nandyalu/trailarr)
Expand All @@ -28,6 +28,8 @@ Documentation: [https://nandyalu.github.io/trailarr](https://nandyalu.github.io/

Reddit: [https://www.reddit.com/r/trailarr](https://www.reddit.com/r/trailarr)

Discord: [https://discord.gg/BAJsv76N](https://discord.gg/BAJsv76N)

## Features

- Manages multiple Radarr and Sonarr instances to find media
Expand Down Expand Up @@ -64,7 +66,7 @@ Trailarr is built using the following libraries and tools:

## Support

If you need help, please craete an issue on the [GitHub repository](https://github.com/nandyalu/issues) or post a question on [Reddit](https://www.reddit.com/r/trailarr/).
If you have any questions or need help, please read the [FAQ](https://nandyalu.github.io/trailarr/help/faq/) first. If you still need help, please create an issue on the [GitHub repository](https://github.com/nandyalu/issues) or post a question on [Reddit](https://www.reddit.com/r/trailarr/) or join our [Discord](https://discord.gg/BAJsv76N) (recommended).

## Issues

Expand Down
17 changes: 11 additions & 6 deletions assets/openapi/swagger-dark-ui.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 56 additions & 3 deletions backend/api/v1/logs.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,38 @@
import collections
from datetime import datetime, timezone
import logging
import re
import aiofiles
from aiofiles import os as async_os
import os
from fastapi import APIRouter

from api.v1.models import Log
from config.settings import app_settings


logs_router = APIRouter(prefix="/logs", tags=["Logs"])


@logs_router.get("/")
async def get_logs(page: int = 1, limit: int = 100) -> list[str]:
async def get_logs(page: int = 1, limit: int = 100) -> list[Log]:
# Read logs from file and send it back
logs_dir = os.path.abspath(os.path.join(app_settings.app_data_dir, "logs"))
# logs: list[str] = []
logs: collections.deque = collections.deque(maxlen=limit)
if not await async_os.path.exists(logs_dir):
logging.info("Logs directory does not exist")
return ["No logs found"]
return [
Log(
datetime=f"{datetime.now(timezone.utc)}",
level="INFO",
filename="Other",
lineno=1,
module="Other",
message="No Logs Found",
raw_log="No Logs Found",
)
]
for log_file in await async_os.listdir(logs_dir):
if log_file.endswith(".log"):
# logging.info(f"Reading logs from {log_file}")
Expand All @@ -28,9 +41,49 @@ async def get_logs(page: int = 1, limit: int = 100) -> list[str]:
# logs.append(line)
file = await aiofiles.open(f"{logs_dir}/{log_file}", mode="r")
async for line in file:
logs.append(line)
loggg = convert_log(line)
logs.append(loggg)

logs.reverse()
return list(logs)
# logs_filtered = logs[(page - 1) * limit : page * limit]
# return logs_filtered


LOG_REGEX = re.compile(
r"^(?P<datetime>[^\s]+)\s\[(?P<level>[^\|]+)\|(?P<filename>[^\|]+)\|L(?P<lineno>\d+)\]"
r":\s(?P<message>.*)$"
)
LOG_MSG_REGEX = re.compile(r"^(?P<module>[\w]+):\s(?P<message>.*)$")


def convert_log(log: str) -> Log:
match_log = LOG_REGEX.search(log)
if match_log:
module = "Other"
message = match_log.group("message")
match_module = LOG_MSG_REGEX.search(message)
if message.lower().startswith("job"):
module = "Tasks"
if match_module:
module = match_module.group("module")
message = match_module.group("message")
log_obj = Log(
datetime=match_log.group("datetime"),
level=match_log.group("level"),
filename=match_log.group("filename"),
lineno=int(match_log.group("lineno")),
module=module,
message=message,
raw_log=log,
)
return log_obj
return Log(
datetime=f"{datetime.now(timezone.utc)}",
level="INFO",
filename="Other",
lineno=1,
module="Other",
message=log,
raw_log=log,
)
Loading

0 comments on commit c007f4f

Please sign in to comment.