Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle status codes different to OK in HTTP Responses in Cardigann #301

Open
1 task done
oier26 opened this issue Jan 25, 2023 · 2 comments
Open
1 task done

Handle status codes different to OK in HTTP Responses in Cardigann #301

oier26 opened this issue Jan 25, 2023 · 2 comments
Labels
Area: Cardigann Requires Cardigann enhancements in Prowlarr Type: Feature Request

Comments

@oier26
Copy link

oier26 commented Jan 25, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe

I am trying to create a custom version of the BT4G indexer, but I have noticed that, when the indexer does not find any result, Prowlarr is interpreting this as an IndexerError.

Example: https://bt4g.org/search/this%20is%20definitely%20not%20working

HTTP Error - Res: [GET] https://bt4g.org/search/pctfenix%20Last%20Of%20Us%20Cap.102: 404.NotFound (6612 bytes)

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="theme-color" content="#212121">
<title>Download pctfenix Last Of Us Cap.102 Torrents - BT4G</title>
<meta name="keywords" content="pctfenix Last Of Us Cap.102" />
<meta property="og:title" content="pctfenix Last Of Us Cap.102 Search Result - BT4G" />
<meta property="og:site_name" content="BT4G" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon">
<link rel="icon" href="/static/favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="/static/style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body>
<header id="header">
<nav class="teal lighten-1" role="navigation">
<div class="nav-wrapper container">
<a href="/" class="brand-logo">BT4G</a>
<a href="#" data-target="mobile-sidenav" class="sidenav-trigger"><i class="material-icons">menu</i></a>
<ul class="right hide-on-med-and-down">
<li><a class="dark-toggle" href="#" onclick="changeTheme()" title="Dark/light"><i class="material-icons left" id="dark_mode">brightness_4</i></a></li>
<li><a class="dropdown-trigger" href="#!" data-target="dropdown">Language<i class="material-icons left">language</i></a></li>
</ul>
</div>
</nav>
<script>
            check()
            function changeTheme(){
                document.querySelector("body").classList.item(0) === "dark"
                    ? (document.querySelector("body").classList.remove("dark") || get("/cookies/light"))
                    : (document.querySelector("body").classList.add("dark") || get("/cookies/dark"));
                check();
            }
            function check(){
                document.getElementById("dark_mode").innerHTML = document.querySelector("body").classList.item(0) === "dark"
                    ? "brightness_high" : "brightness_4";
            }
            function get(url,theme) {
                const xmlHttp = new XMLHttpRequest();
                xmlHttp.open("GET", url, true);
                xmlHttp.send(null);
            }
        </script>
<ul id="dropdown" class="dropdown-content">
<li> <a class="grey-text text-darken-4" href="//bt4g.org/search/pctfenix%20Last%20Of%20Us%20Cap.102">English</a></li>
<li> <a class="grey-text text-darken-4" href="//es.bt4g.org/search/pctfenix%20Last%20Of%20Us%20Cap.102">Español</a></li>
<li> <a class="grey-text text-darken-4" href="//kr.bt4g.org/search/pctfenix%20Last%20Of%20Us%20Cap.102">한국어</a></li>
<li> <a class="grey-text text-darken-4" href="//jp.bt4g.org/search/pctfenix%20Last%20Of%20Us%20Cap.102">日本語</a></li>
</ul>
<ul class="sidenav" id="mobile-sidenav">
</ul>
</header>
<main>
<div class="container">
<div class="row search_div">
<form class="col s12">
<div class="row search_div">
<div class="input-field col s9 l10 m10">
<label for="search"></label>
<input type="text" id="search" autocomplete="off" placeholder="Enter Keywords to search" class="autocomplete input-field inline" value="pctfenix Last Of Us Cap.102" />
</div>
<div class="input-field col s3 l2 m2">
<button class="btn" type="submit">search</button>
</div>
</div>
</form>
</div>
<div class="row">
<div class="col s12">
<span>Your search - <em style="font-weight: bold;font-style: normal;">pctfenix Last Of Us Cap.102</em> - did not match any documents. </span>

<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="20" height="20" viewBox="0 0 455.731 455.731" style="enable-background:new 0 0 455.731 455.731;" xml:space="preserve">
<g>
<a target="_blank" xlink:href="?page=rss">
<rect x="0" y="0" style="fill:#F78422;" width="455.731" height="455.731" />
<g>
<path style="fill:#FFFFFF;" d="M296.208,159.16C234.445,97.397,152.266,63.382,64.81,63.382v64.348
            c70.268,0,136.288,27.321,185.898,76.931c49.609,49.61,76.931,115.63,76.931,185.898h64.348
            C391.986,303.103,357.971,220.923,296.208,159.16z" />
<path style="fill:#FFFFFF;" d="M64.143,172.273v64.348c84.881,0,153.938,69.056,153.938,153.939h64.348
            C282.429,270.196,184.507,172.273,64.143,172.273z" />
<circle style="fill:#FFFFFF;" cx="109.833" cy="346.26" r="46.088" />
</g>
</a>
</g>
</svg>
<p style="margin-top:1em">Suggestions:</p>
<ul style="margin-left:1.3em;margin-bottom:2em">
<li>Make sure all words are spelled correctly.</li>
<li>Try different keywords.</li>
<li>Try more general keywords.</li>
</ul>
</div>
</div>
</div>
</main>
<footer class="page-footer grey darken-4">
<div class="footer-copyright">
<div class="container">
<p class="left">© bt4g.com</p>
<p>
<a class="right grey-text text-lighten-2" href="/dmca" rel="nofollow">dmca&nbsp;</a>
<a class="right grey-text text-lighten-2" href="/week">hot&nbsp;</a>
<a class="right grey-text text-lighten-2" href="/new">recent&nbsp;</a>
<br>
<p class="grey-text footer-info" style="text-align:left">BT4G (bt4g.com) is not a tracker and doesn't store any content and only collects torrent metadata (such as file names and file sizes) and a magnet link (torrent identifier).</p>
</div>
</div>
</footer>

<script type="text/javascript">
        document.addEventListener('DOMContentLoaded', function() {
            let sidenav = document.querySelectorAll('.sidenav');
            M.Sidenav.init(sidenav);
            let dropdown_trigger = document.querySelectorAll('.dropdown-trigger');
            M.Dropdown.init(dropdown_trigger);
            let tabs = document.querySelectorAll('.tabs');
            M.Tabs.init(tabs);
        });
        
        document.forms[0].onsubmit = function (e) {
            e.preventDefault();
            let query = document.getElementById("search").value;
            if (!query) {
                document.getElementById("search").focus();
                return false;
            }
            window.location = '/search/' + encodeURIComponent(query); return false;
        };
    </script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/instant.page/5.1.1/instantpage.min.js"></script>
<script src='/static/s.js'></script>
<script async src="https://www.googletagmanager.com/gtag/js?id=(removed)"></script>
<script>window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}gtag('js', new Date());gtag('config', 'UA-163225115-1');</script>
</body>
</html>

This is due to the fact that the indexer is returning a 404 status code when it does not find any result in the indexer. However, the response is correct.

Describe the solution you'd like

Add a tag in Cardigann to handle errors in search in which, apart from the selectors received, the status code can be defined.

search:
  error:
    - selector: div.error
    - statusCode: 404

Describe alternatives you've considered

Write the code for the indexer in C#

Anything else?

Condition is found in: https://github.com/Prowlarr/Prowlarr/blob/develop/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannParser.cs
Line 41

AB#4802

@bakerboy448
Copy link
Collaborator

@ilike2burnthing @garfield69

certainly something worth looking into; thoughts?

There's already noResultsMessage concept for JSON. But there's probably more valid/better errors to handle besides just 404 as no results

@ilike2burnthing
Copy link
Contributor

I don't think there would be any issue for Jackett if this was added, but to my knowledge it currently doesn't make any difference to Jackett if there's an error or just zero results (for the sake of oier26, I'm not a C# dev).

@bakerboy448 bakerboy448 added Area: Cardigann Requires Cardigann enhancements in Prowlarr and removed Status: Needs Triage labels May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Cardigann Requires Cardigann enhancements in Prowlarr Type: Feature Request
Projects
None yet
Development

No branches or pull requests

3 participants