Poller #9
41
README.md
41
README.md
@ -7,17 +7,50 @@ drmdtool is a utility for processing .drmd files using N_m3u8DL-RE.
|
|||||||
Create a `config.toml` file in the same directory as the drmdtool executable:
|
Create a `config.toml` file in the same directory as the drmdtool executable:
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
|
[General]
|
||||||
BaseDir = "/path/to/save/downloads"
|
BaseDir = "/path/to/save/downloads"
|
||||||
Format = "mkv"
|
Format = "mkv"
|
||||||
TempBaseDir = "/tmp/nre"
|
TempBaseDir = "/tmp/nre"
|
||||||
EnableConsole = true
|
EnableConsole = true
|
||||||
WatchedFolder = "/path/to/watched/folder"
|
|
||||||
|
|
||||||
[N_m3u8DL-RE]
|
[WatchFolder]
|
||||||
|
Path = "/path/to/watched/folder"
|
||||||
|
PollingInterval = 10
|
||||||
|
UsePolling = true
|
||||||
|
UseInotify = false
|
||||||
|
|
||||||
|
[N_m3u8DLRE]
|
||||||
Path = "/path/to/N_m3u8DL-RE"
|
Path = "/path/to/N_m3u8DL-RE"
|
||||||
```
|
```
|
||||||
|
|
||||||
Adjust the paths and format as needed. (mkv, mp4)
|
### Configuration Options
|
||||||
|
|
||||||
|
- **General**
|
||||||
|
- `BaseDir`: Directory where downloaded files will be saved.
|
||||||
|
- `Format`: Output format for the downloaded files (e.g., `mkv`, `mp4`).
|
||||||
|
- `TempBaseDir`: Temporary directory for intermediate files.
|
||||||
|
- `EnableConsole`: Boolean to enable or disable console output.
|
||||||
|
|
||||||
|
- **WatchFolder**
|
||||||
|
- `Path`: Directory to watch for new `.drmd` files.
|
||||||
|
- `PollingInterval`: Interval in seconds for polling the watch folder.
|
||||||
|
- `UsePolling`: Boolean to enable or disable folder polling.
|
||||||
|
- `UseInotify`: Boolean to enable or disable inotify for file watching.
|
||||||
|
|
||||||
|
- **N_m3u8DLRE**
|
||||||
|
- `Path`: Path to the N_m3u8DL-RE executable.
|
||||||
|
|
||||||
|
### Environment Variable Overrides
|
||||||
|
|
||||||
|
You can override the configuration options using environment variables. The following environment variables are supported:
|
||||||
|
|
||||||
|
- `BASE_DIR`: Overrides `General.BaseDir`
|
||||||
|
- `FORMAT`: Overrides `General.Format`
|
||||||
|
- `TEMP_BASE_DIR`: Overrides `General.TempBaseDir`
|
||||||
|
- `WATCHED_FOLDER`: Overrides `WatchFolder.Path`
|
||||||
|
- `USE_POLLING`: Overrides `WatchFolder.UsePolling` (set to `true` or `false`)
|
||||||
|
- `USE_INOTIFY`: Overrides `WatchFolder.UseInotify` (set to `true` or `false`)
|
||||||
|
- `POLLING_INTERVAL`: Overrides `WatchFolder.PollingInterval`
|
||||||
|
|
||||||
## Web UI Usage
|
## Web UI Usage
|
||||||
|
|
||||||
@ -30,7 +63,6 @@ Adjust the paths and format as needed. (mkv, mp4)
|
|||||||
|
|
||||||
3. Use the interface to upload .drmd files and monitor download progress
|
3. Use the interface to upload .drmd files and monitor download progress
|
||||||
|
|
||||||
|
|
||||||
## CLI Usage
|
## CLI Usage
|
||||||
|
|
||||||
To process a file directly from the command line:
|
To process a file directly from the command line:
|
||||||
@ -41,7 +73,6 @@ To process a file directly from the command line:
|
|||||||
|
|
||||||
This will download the file and save it in the base directory specified in the config.
|
This will download the file and save it in the base directory specified in the config.
|
||||||
|
|
||||||
|
|
||||||
# Previews
|
# Previews
|
||||||
|
|
||||||
## Index Page
|
## Index Page
|
||||||
|
@ -13,6 +13,16 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func watchFolder() {
|
func watchFolder() {
|
||||||
|
if config.WatchFolder.UsePolling {
|
||||||
|
go pollFolder()
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.WatchFolder.UseInotify {
|
||||||
|
go inotifyWatch()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func inotifyWatch() {
|
||||||
watcher, err := fsnotify.NewWatcher()
|
watcher, err := fsnotify.NewWatcher()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
@ -43,13 +53,31 @@ func watchFolder() {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
err = watcher.Add(config.WatchedFolder)
|
err = watcher.Add(config.WatchFolder.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
<-done
|
<-done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func pollFolder() {
|
||||||
|
ticker := time.NewTicker(time.Duration(config.WatchFolder.PollingInterval) * time.Second)
|
||||||
|
defer ticker.Stop()
|
||||||
|
|
||||||
|
for range ticker.C {
|
||||||
|
files, err := filepath.Glob(filepath.Join(config.WatchFolder.Path, "*.drmd"))
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error polling folder:", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, file := range files {
|
||||||
|
fmt.Println("New .drmd detected via polling:", file)
|
||||||
|
go processWatchedFile(file)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func processWatchedFile(filePath string) {
|
func processWatchedFile(filePath string) {
|
||||||
for {
|
for {
|
||||||
initialSize, err := getFileSize(filePath)
|
initialSize, err := getFileSize(filePath)
|
||||||
|
Loading…
Reference in New Issue
Block a user