hydrus/help/downloader_parsers.html

39 lines
3.4 KiB
HTML

<html>
<head>
<title>downloader - parsers</title>
<link href="hydrus.ico" rel="shortcut icon" />
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="content">
<p><a href="downloader_url_classes.html"><---- Back to URL Classes</a></p>
<h3 id="intro"><a href="#intro">parsers</a></h3>
<p>In hydrus, a parser is an object that takes a single block of HTML or JSON data and returns many kinds of hydrus-level metadata.</p>
<p>Parsers are flexible and potentially quite complicated. You might like to open <i>network->manage parsers</i> and explore the UI as you read these pages. Check out how the default parsers already in the client work, and if you want to write a new one, see if there is something already in there that is similar--it is usually easier to duplicate an existing parser and then alter it than to create a new one from scratch every time.</p>
<p>There are three main components in the parsing system (click to open each component's help page):</p>
<ul>
<li><a href="downloader_parsers_formulae.html"><b>Formulae:</b></a> Take parsable data, search it in some manner, and return 0 to n strings.</li>
<li><a href="downloader_parsers_content_parsers.html"><b>Content Parsers:</b></a> Take parsable data, apply a formula to it to get some strings, and apply a single metadata 'type' and perhaps some additional modifiers.</li>
<li><a href="downloader_parsers_page_parsers.html"><b>Page Parsers:</b></a> Take parsable data, apply content parsers to it, and return all the metadata in an appropriate structure.</li>
</ul>
<p>Once you are comfortable with these objects, you might like to check out these walkthroughs, which create full parsers from nothing:</p>
<ul>
<li><a href="downloader_parsers_full_example_gallery_page.html">e621 HTML gallery page</a></li>
<li><a href="downloader_parsers_full_example_file_page.html">Gelbooru HTML file page</a></li>
<li><a href="downloader_parsers_full_example_api.html">Artstation JSON file page API</a></li>
</ul>
<p>Once you are comfortable with parsers, and if you are feeling brave, check out how the default imageboard and pixiv parsers work. These are complicated and use more experimental areas of the code to get their job done. If you are trying to get a new imageboard parser going and can't figure out subsidiary page parsers, send me a mail or something and I'll try to help you out!</p>
<p>When you are making a parser, consider this checklist (you might want to copy/have your own version of this somewhere):</p>
<ul>
<li>Do you get good URLs with good priority? Do you ever accidentally get favourite/popular/advert results you didn't mean to?</li>
<li>If you need a next gallery page URL, is it ever not available (and hence needs a URL Class fix)? Does it change for search tags with unicode or http-restricted characters?</li>
<li>Do you get nice namespaced tags? Are any unwanted single characters like -/+/? getting through?</li>
<li>Is the file hash available anywhere?</li>
<li>Is a source/post time available?</li>
<li>Is a source URL available? Is it good quality, or does it often just point to an artist's base twitter profile? If you pull it from text or a tooltip, is it clipped for longer URLs?</li>
</ul>
<p class="right"><a href="downloader_completion.html">Taken a break? Now let's put it all together ----></a></p>
</div>
</body>
</html>