From 969a9e7025499d4ecc79736483e3862f31b62578 Mon Sep 17 00:00:00 2001 From: ze0s <43699394+zze0s@users.noreply.github.com> Date: Fri, 14 Apr 2023 21:15:32 +0200 Subject: [PATCH] fix(indexers): PolishSource downloads (#837) * test: dump req and res for torrent download * chore: remove req res dump --- internal/domain/release.go | 14 ++++++++------ internal/indexer/definitions/polishsource.yaml | 8 ++++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/internal/domain/release.go b/internal/domain/release.go index 7cd1f32..6e8a7ea 100644 --- a/internal/domain/release.go +++ b/internal/domain/release.go @@ -332,16 +332,10 @@ func (r *Release) downloadTorrentFile(ctx context.Context) error { return nil } - jar, err := cookiejar.New(&cookiejar.Options{PublicSuffixList: publicsuffix.List}) - if err != nil { - return errors.Wrap(err, "could not create cookiejar") - } - customTransport := http.DefaultTransport.(*http.Transport).Clone() customTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} client := &http.Client{ Transport: customTransport, - Jar: jar, Timeout: time.Second * 45, } @@ -350,7 +344,15 @@ func (r *Release) downloadTorrentFile(ctx context.Context) error { return errors.Wrap(err, "error downloading file") } + req.Header.Set("User-Agent", "autobrr") + if r.RawCookie != "" { + jar, err := cookiejar.New(&cookiejar.Options{PublicSuffixList: publicsuffix.List}) + if err != nil { + return errors.Wrap(err, "could not create cookiejar") + } + client.Jar = jar + // set the cookie on the header instead of req.AddCookie // since we have a raw cookie like "uid=10; pass=000" req.Header.Set("Cookie", r.RawCookie) diff --git a/internal/indexer/definitions/polishsource.yaml b/internal/indexer/definitions/polishsource.yaml index 892c098..1566d40 100644 --- a/internal/indexer/definitions/polishsource.yaml +++ b/internal/indexer/definitions/polishsource.yaml @@ -58,9 +58,9 @@ irc: type: single lines: - test: - - "Some.Show.S09E01.HDTV.x264-GROUP > TV/SD > 359.285 MB / 2 F > [ http://polishsource.cz/details.php?id=000000 ]-[ 5h 25min 15sec after pre ]" - - "Some.Movie.2011.DVDRip.x264-GROUP2 > Movies/x264 (Documentary) > 563.296 MB / 2 F > [ http://polishsource.cz/details.php?id=000000 ]-[ 2min 48sec after pre ]" - pattern: '(.*) > (.*) > (.*) \/.*>\s*\[ (https?\:\/\/.+\/).*[&?]id=(\d+)\s\](?:-\[ (.*) \])?' + - " Some.Show.S09E01.HDTV.x264-GROUP > TV/SD > 359.285 MB / 2 F > [ http://polishsource.cz/details.php?id=000000 ]-[ 5h 25min 15sec after pre ]" + - " Some.Movie.2011.DVDRip.x264-GROUP2 > Movies/x264 (Documentary) > 563.296 MB / 2 F > [ http://polishsource.cz/details.php?id=000000 ]-[ 2min 48sec after pre ]" + pattern: '^ (.*) > (.*) > (.*) \/.*>\s*\[ (https?\:\/\/.+\/).*[&?]id=(\d+)\s\](?:-\[ (.*) \])?' vars: - torrentName - category @@ -71,6 +71,6 @@ irc: match: infourl: "/details.php?id={{ .torrentId }}" - torrenturl: "/downloadssl.php?id={{ .torrentId }}&torr={{ .torrentName }}.torrent&passkey={{ .passkey }}" + torrenturl: "/download.php?id={{ .torrentId }}&torr={{ .torrentName }}.torrent&passkey={{ .passkey }}" encode: - torrentName