Changelog 0.3.1
This commit is contained in:
@@ -14,7 +14,7 @@ tmp_dir = "tmp"
|
|||||||
follow_symlink = false
|
follow_symlink = false
|
||||||
full_bin = ""
|
full_bin = ""
|
||||||
include_dir = []
|
include_dir = []
|
||||||
include_ext = ["go", "tpl", "tmpl", "html"]
|
include_ext = ["go", "tpl", "tmpl", "html", ".json"]
|
||||||
include_file = []
|
include_file = []
|
||||||
kill_delay = "0s"
|
kill_delay = "0s"
|
||||||
log = "build-errors.log"
|
log = "build-errors.log"
|
||||||
|
|||||||
15
.github/workflows/docker.yml
vendored
15
.github/workflows/docker.yml
vendored
@@ -40,8 +40,8 @@ jobs:
|
|||||||
push: true
|
push: true
|
||||||
tags: cy01/blackhole:beta
|
tags: cy01/blackhole:beta
|
||||||
|
|
||||||
- name: Build and push for main branch with version
|
- name: Build and push for main branch
|
||||||
if: github.ref == 'refs/heads/main' && steps.get_version.outputs.VERSION != ''
|
if: github.ref == 'refs/heads/main'
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
@@ -49,13 +49,4 @@ jobs:
|
|||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: |
|
||||||
cy01/blackhole:latest
|
cy01/blackhole:latest
|
||||||
cy01/blackhole:${{ steps.get_version.outputs.VERSION }}
|
cy01/blackhole:${{ steps.get_version.outputs.VERSION }}
|
||||||
|
|
||||||
- name: Build and push for main branch without version
|
|
||||||
if: github.ref == 'refs/heads/main' && steps.get_version.outputs.VERSION == ''
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
|
||||||
push: true
|
|
||||||
tags: cy01/blackhole:latest
|
|
||||||
@@ -91,4 +91,9 @@
|
|||||||
- Refraction of the code
|
- Refraction of the code
|
||||||
- -Fix Torbox bug
|
- -Fix Torbox bug
|
||||||
- Update CI/CD
|
- Update CI/CD
|
||||||
- Update Readme
|
- Update Readme
|
||||||
|
|
||||||
|
#### 0.3.1
|
||||||
|
|
||||||
|
- Add DebridLink Support
|
||||||
|
- Refactor error handling
|
||||||
20
README.md
20
README.md
@@ -9,13 +9,16 @@ This is a Golang implementation go Torrent QbitTorrent with a **Real Debrid & To
|
|||||||
- Proxy support for the Arrs
|
- Proxy support for the Arrs
|
||||||
- Real Debrid Support
|
- Real Debrid Support
|
||||||
- Torbox Support
|
- Torbox Support
|
||||||
|
- Debrid Link Support
|
||||||
- Multi-Debrid Providers support
|
- Multi-Debrid Providers support
|
||||||
|
- UI for adding torrents directly to *arrs
|
||||||
|
|
||||||
The proxy is useful in filtering out un-cached Real Debrid torrents
|
The proxy is useful in filtering out un-cached Real Debrid torrents
|
||||||
|
|
||||||
### Supported Debrid Providers
|
### Supported Debrid Providers
|
||||||
- Real Debrid
|
- Real Debrid
|
||||||
- Torbox
|
- Torbox
|
||||||
|
- Debrid Link
|
||||||
|
|
||||||
### Changelog
|
### Changelog
|
||||||
|
|
||||||
@@ -66,7 +69,7 @@ Download the binary from the releases page and run it with the config file.
|
|||||||
"name": "torbox",
|
"name": "torbox",
|
||||||
"host": "https://api.torbox.app/v1",
|
"host": "https://api.torbox.app/v1",
|
||||||
"api_key": "torbox_api_key",
|
"api_key": "torbox_api_key",
|
||||||
"folder": "data/realdebrid/torrents/",
|
"folder": "data/torbox/torrents/",
|
||||||
"rate_limit": "250/minute",
|
"rate_limit": "250/minute",
|
||||||
"download_uncached": false,
|
"download_uncached": false,
|
||||||
"check_cached": true
|
"check_cached": true
|
||||||
@@ -79,6 +82,15 @@ Download the binary from the releases page and run it with the config file.
|
|||||||
"rate_limit": "250/minute",
|
"rate_limit": "250/minute",
|
||||||
"download_uncached": false,
|
"download_uncached": false,
|
||||||
"check_cached": false
|
"check_cached": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "debridlink",
|
||||||
|
"host": "https://debrid-link.com/api/v2",
|
||||||
|
"api_key": "debridlink_key",
|
||||||
|
"folder": "data/debridlink/torrents/",
|
||||||
|
"rate_limit": "250/minute",
|
||||||
|
"download_uncached": false,
|
||||||
|
"check_cached": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"proxy": {
|
"proxy": {
|
||||||
@@ -163,6 +175,12 @@ Setting Up Qbittorrent in Arr
|
|||||||
- Test
|
- Test
|
||||||
- Save
|
- Save
|
||||||
|
|
||||||
|
### UI for adding torrents
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
The UI is a simple web interface that allows you to add torrents directly to the Arrs(Sonarr, Radarr, etc)
|
||||||
|
|
||||||
### TODO
|
### TODO
|
||||||
- [ ] A proper name!!!!
|
- [ ] A proper name!!!!
|
||||||
- [ ] Debrid
|
- [ ] Debrid
|
||||||
|
|||||||
@@ -75,7 +75,9 @@ func (c *RLHTTPClient) MakeRequest(req *http.Request) ([]byte, error) {
|
|||||||
b, _ := io.ReadAll(res.Body)
|
b, _ := io.ReadAll(res.Body)
|
||||||
statusOk := strconv.Itoa(res.StatusCode)[0] == '2'
|
statusOk := strconv.Itoa(res.StatusCode)[0] == '2'
|
||||||
if !statusOk {
|
if !statusOk {
|
||||||
return nil, fmt.Errorf("unexpected status code: %d", res.StatusCode)
|
// Add status code error to the body
|
||||||
|
b = append(b, []byte(fmt.Sprintf("\nstatus code: %d", res.StatusCode))...)
|
||||||
|
return nil, fmt.Errorf(string(b))
|
||||||
}
|
}
|
||||||
defer func(Body io.ReadCloser) {
|
defer func(Body io.ReadCloser) {
|
||||||
err := Body.Close()
|
err := Body.Close()
|
||||||
|
|||||||
BIN
doc/ui.png
Normal file
BIN
doc/ui.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 124 KiB |
@@ -147,6 +147,8 @@ func ProcessTorrent(d *DebridService, magnet *common.Magnet, a *arr.Arr, isSymli
|
|||||||
Size: magnet.Size,
|
Size: magnet.Size,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
errs := make([]error, 0)
|
||||||
|
|
||||||
for index, db := range d.debrids {
|
for index, db := range d.debrids {
|
||||||
log.Println("Processing debrid: ", db.GetName())
|
log.Println("Processing debrid: ", db.GetName())
|
||||||
logger := db.GetLogger()
|
logger := db.GetLogger()
|
||||||
@@ -162,18 +164,21 @@ func ProcessTorrent(d *DebridService, magnet *common.Magnet, a *arr.Arr, isSymli
|
|||||||
}
|
}
|
||||||
|
|
||||||
dbt, err := db.SubmitMagnet(debridTorrent)
|
dbt, err := db.SubmitMagnet(debridTorrent)
|
||||||
if err != nil || dbt.Id == "" {
|
if dbt != nil {
|
||||||
if dbt != nil {
|
dbt.Debrid = db
|
||||||
dbt.Delete()
|
dbt.Arr = a
|
||||||
}
|
}
|
||||||
logger.Printf("Error submitting magnet: %s", err)
|
if err != nil || dbt == nil || dbt.Id == "" {
|
||||||
|
errs = append(errs, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
logger.Printf("Torrent: %s submitted to %s", dbt.Name, db.GetName())
|
logger.Printf("Torrent: %s submitted to %s", dbt.Name, db.GetName())
|
||||||
d.lastUsed = index
|
d.lastUsed = index
|
||||||
dbt.Debrid = db
|
|
||||||
dbt.Arr = a
|
|
||||||
return db.CheckStatus(dbt, isSymlink)
|
return db.CheckStatus(dbt, isSymlink)
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("failed to process torrent")
|
err := fmt.Errorf("failed to process torrent")
|
||||||
|
for _, e := range errs {
|
||||||
|
err = fmt.Errorf("%w\n%w", err, e)
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ func (r *DebridLink) IsAvailable(infohashes []string) map[string]bool {
|
|||||||
|
|
||||||
func (r *DebridLink) GetTorrent(id string) (*Torrent, error) {
|
func (r *DebridLink) GetTorrent(id string) (*Torrent, error) {
|
||||||
torrent := &Torrent{}
|
torrent := &Torrent{}
|
||||||
url := fmt.Sprintf("%s/seedbox/list/?ids=%s", r.Host, id)
|
url := fmt.Sprintf("%s/seedbox/list?ids=%s", r.Host, id)
|
||||||
req, _ := http.NewRequest(http.MethodGet, url, nil)
|
req, _ := http.NewRequest(http.MethodGet, url, nil)
|
||||||
resp, err := r.client.MakeRequest(req)
|
resp, err := r.client.MakeRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -113,6 +113,9 @@ func (r *DebridLink) GetTorrent(id string) (*Torrent, error) {
|
|||||||
}
|
}
|
||||||
data := dt[0]
|
data := dt[0]
|
||||||
status := "downloading"
|
status := "downloading"
|
||||||
|
if data.Status == 100 {
|
||||||
|
status = "downloaded"
|
||||||
|
}
|
||||||
name := common.RemoveInvalidChars(data.Name)
|
name := common.RemoveInvalidChars(data.Name)
|
||||||
torrent.Id = data.ID
|
torrent.Id = data.ID
|
||||||
torrent.Name = name
|
torrent.Name = name
|
||||||
@@ -185,8 +188,8 @@ func (r *DebridLink) SubmitMagnet(torrent *Torrent) (*Torrent, error) {
|
|||||||
|
|
||||||
func (r *DebridLink) CheckStatus(torrent *Torrent, isSymlink bool) (*Torrent, error) {
|
func (r *DebridLink) CheckStatus(torrent *Torrent, isSymlink bool) (*Torrent, error) {
|
||||||
for {
|
for {
|
||||||
torrent, err := r.GetTorrent(torrent.Id)
|
t, err := r.GetTorrent(torrent.Id)
|
||||||
|
torrent = t
|
||||||
if err != nil || torrent == nil {
|
if err != nil || torrent == nil {
|
||||||
return torrent, err
|
return torrent, err
|
||||||
}
|
}
|
||||||
@@ -248,6 +251,7 @@ func NewDebridLink(dc common.DebridConfig, cache *common.Cache) *DebridLink {
|
|||||||
rl := common.ParseRateLimit(dc.RateLimit)
|
rl := common.ParseRateLimit(dc.RateLimit)
|
||||||
headers := map[string]string{
|
headers := map[string]string{
|
||||||
"Authorization": fmt.Sprintf("Bearer %s", dc.APIKey),
|
"Authorization": fmt.Sprintf("Bearer %s", dc.APIKey),
|
||||||
|
"Content-Type": "application/json",
|
||||||
}
|
}
|
||||||
client := common.NewRLHTTPClient(rl, headers)
|
client := common.NewRLHTTPClient(rl, headers)
|
||||||
logger := common.NewLogger(dc.Name, os.Stdout)
|
logger := common.NewLogger(dc.Name, os.Stdout)
|
||||||
|
|||||||
@@ -180,12 +180,11 @@ func (r *RealDebrid) CheckStatus(torrent *Torrent, isSymlink bool) (*Torrent, er
|
|||||||
torrent.Status = status
|
torrent.Status = status
|
||||||
torrent.Debrid = r
|
torrent.Debrid = r
|
||||||
if status == "error" || status == "dead" || status == "magnet_error" {
|
if status == "error" || status == "dead" || status == "magnet_error" {
|
||||||
return torrent, fmt.Errorf("torrent: %s has error", torrent.Name)
|
return torrent, fmt.Errorf("torrent: %s has error: %s", torrent.Name, status)
|
||||||
} else if status == "waiting_files_selection" {
|
} else if status == "waiting_files_selection" {
|
||||||
files := GetTorrentFiles(data)
|
files := GetTorrentFiles(data)
|
||||||
torrent.Files = files
|
torrent.Files = files
|
||||||
if len(files) == 0 {
|
if len(files) == 0 {
|
||||||
go torrent.Delete()
|
|
||||||
return torrent, fmt.Errorf("no video files found")
|
return torrent, fmt.Errorf("no video files found")
|
||||||
}
|
}
|
||||||
filesId := make([]string, 0)
|
filesId := make([]string, 0)
|
||||||
@@ -214,7 +213,6 @@ func (r *RealDebrid) CheckStatus(torrent *Torrent, isSymlink bool) (*Torrent, er
|
|||||||
break
|
break
|
||||||
} else if status == "downloading" {
|
} else if status == "downloading" {
|
||||||
if !r.DownloadUncached {
|
if !r.DownloadUncached {
|
||||||
go torrent.Delete()
|
|
||||||
return torrent, fmt.Errorf("torrent: %s not cached", torrent.Name)
|
return torrent, fmt.Errorf("torrent: %s not cached", torrent.Name)
|
||||||
}
|
}
|
||||||
// Break out of the loop if the torrent is downloading.
|
// Break out of the loop if the torrent is downloading.
|
||||||
|
|||||||
@@ -74,7 +74,11 @@ func (t *Torrent) GetMountFolder(rClonePath string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *Torrent) Delete() {
|
func (t *Torrent) Delete() {
|
||||||
|
if t.Debrid == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
t.Debrid.DeleteTorrent(t)
|
t.Debrid.DeleteTorrent(t)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type TorrentFile struct {
|
type TorrentFile struct {
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ func (s *Server) handleTorrentsAdd(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx = context.WithValue(ctx, "isSymlink", isSymlink)
|
ctx = context.WithValue(ctx, "isSymlink", isSymlink)
|
||||||
|
|
||||||
for _, url := range urlList {
|
for _, url := range urlList {
|
||||||
if err := s.qbit.AddMagnet(ctx, url, category); err != nil {
|
if err := s.qbit.AddMagnet(ctx, url, category); err != nil {
|
||||||
s.logger.Printf("Error adding magnet: %v\n", err)
|
s.logger.Printf("Error adding magnet: %v\n", err)
|
||||||
@@ -59,13 +58,8 @@ func (s *Server) handleTorrentsAdd(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if contentType == "multipart/form-data" {
|
if contentType == "multipart/form-data" && len(r.MultipartForm.File["torrents"]) > 0 {
|
||||||
files := r.MultipartForm.File["torrents"]
|
files := r.MultipartForm.File["torrents"]
|
||||||
if len(files) == 0 {
|
|
||||||
s.logger.Printf("No files provided\n")
|
|
||||||
http.Error(w, "No files provided", http.StatusBadRequest)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
for _, fileHeader := range files {
|
for _, fileHeader := range files {
|
||||||
if err := s.qbit.AddTorrent(ctx, fileHeader, category); err != nil {
|
if err := s.qbit.AddTorrent(ctx, fileHeader, category); err != nil {
|
||||||
s.logger.Printf("Error adding torrent: %v\n", err)
|
s.logger.Printf("Error adding torrent: %v\n", err)
|
||||||
|
|||||||
@@ -21,13 +21,11 @@ import (
|
|||||||
func (q *QBit) AddMagnet(ctx context.Context, url, category string) error {
|
func (q *QBit) AddMagnet(ctx context.Context, url, category string) error {
|
||||||
magnet, err := common.GetMagnetFromUrl(url)
|
magnet, err := common.GetMagnetFromUrl(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
q.logger.Printf("Error parsing magnet link: %v\n", err)
|
return fmt.Errorf("error parsing magnet link: %w", err)
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
err = q.Process(ctx, magnet, category)
|
err = q.Process(ctx, magnet, category)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
q.logger.Println("Failed to process magnet:", err)
|
return fmt.Errorf("failed to process torrent: %w", err)
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -38,13 +36,11 @@ func (q *QBit) AddTorrent(ctx context.Context, fileHeader *multipart.FileHeader,
|
|||||||
var reader io.Reader = file
|
var reader io.Reader = file
|
||||||
magnet, err := common.GetMagnetFromFile(reader, fileHeader.Filename)
|
magnet, err := common.GetMagnetFromFile(reader, fileHeader.Filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
q.logger.Printf("Error reading file: %s", fileHeader.Filename)
|
return fmt.Errorf("error reading file: %s \n %w", fileHeader.Filename, err)
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
err = q.Process(ctx, magnet, category)
|
err = q.Process(ctx, magnet, category)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
q.logger.Println("Failed to process torrent:", err)
|
return fmt.Errorf("failed to process torrent: %w", err)
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -58,6 +54,9 @@ func (q *QBit) Process(ctx context.Context, magnet *common.Magnet, category stri
|
|||||||
isSymlink := ctx.Value("isSymlink").(bool)
|
isSymlink := ctx.Value("isSymlink").(bool)
|
||||||
debridTorrent, err := debrid.ProcessTorrent(q.Debrid, magnet, a, isSymlink)
|
debridTorrent, err := debrid.ProcessTorrent(q.Debrid, magnet, a, isSymlink)
|
||||||
if err != nil || debridTorrent == nil {
|
if err != nil || debridTorrent == nil {
|
||||||
|
if debridTorrent != nil {
|
||||||
|
go debridTorrent.Delete()
|
||||||
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = fmt.Errorf("failed to process torrent")
|
err = fmt.Errorf("failed to process torrent")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user