diff options
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | project.conf | 3 | ||||
-rw-r--r-- | src/Body.cpp | 2 | ||||
-rw-r--r-- | src/plugins/Fourchan.cpp | 392 |
4 files changed, 395 insertions, 6 deletions
@@ -1,6 +1,8 @@ # QuickMedia Native clients of websites with fast access to what you want to see, **with TOR support**. See [old video demo with manga](https://beta.lbry.tv/quickmedia_manga-2019-08-05_21.20.46/7).\ -Currently supported websites: `youtube`, `manganelo` and _others_. **Note:** Manganelo doesn't work when used with TOR.\ +Currently supported websites: `youtube`, `manganelo` and _others_.\ +**Note:** Manganelo doesn't work when used with TOR.\ +**Note:** TOR system service needs to be running (`systemctl start tor.service`).\ Here is an example with YouTube:\ ![QuickMedia Youtube Picture](QuickMediaYoutube.png)\ Config data, including manga progress is stored under `$HOME/.config/quickmedia` diff --git a/project.conf b/project.conf index f93e09e..fb21e5d 100644 --- a/project.conf +++ b/project.conf @@ -11,4 +11,5 @@ version = "c++17" sfml-graphics = "2" x11 = "1.6.5" jsoncpp = "1.5" -cppcodec-1 = "0.1"
\ No newline at end of file +cppcodec-1 = "0.1" +tidy = "5"
\ No newline at end of file diff --git a/src/Body.cpp b/src/Body.cpp index 7ed1a7f..db27214 100644 --- a/src/Body.cpp +++ b/src/Body.cpp @@ -222,7 +222,7 @@ namespace QuickMedia { image.setPosition(item_pos); window.draw(image); text_offset_x = width_ratio * image_size.x; - } else { + } else if(!item->thumbnail_url.empty()) { image_fallback.setPosition(item_pos); window.draw(image_fallback); text_offset_x = image_fallback.getSize().x; diff --git a/src/plugins/Fourchan.cpp b/src/plugins/Fourchan.cpp index 0c3bffb..01039b9 100644 --- a/src/plugins/Fourchan.cpp +++ b/src/plugins/Fourchan.cpp @@ -1,6 +1,8 @@ #include "../../plugins/Fourchan.hpp" #include <json/reader.h> #include <string.h> +#include <tidy.h> +#include <tidybuffio.h> // API documentation: https://github.com/4chan/4chan-API @@ -17,6 +19,38 @@ curl 'https://www.google.com/recaptcha/api/fallback?k=6Ldp2bsSAAAAAAJ5uyx_lx34lJ -H 'Content-Type: application/x-www-form-urlencoded' --data 'c=03AOLTBLQ66PjSi9s8S-R1vUS2Jgm-Z_ghEejvvjAaeF3FoR9MiM0zHhCxuertrCo7MAcFUEqcIg4l2WJzVtrJhJVLkncF12OzCaeIvbm46hgDZDZjLD89-LMn1Zs0TP37P-Hd4cuRG8nHuEBXc2ZBD8CVX-6HAs9VBgSmsgQeKF1PWm1tAMBccJhlh4rAOkpjzaEXMMGOe17N0XViwDYZxLGhe4H8IAG2KNB1fb4rz4YKJTPbL30_FvHw7zkdFtojjWiqVW0yCN6N192dhfd9oKz2r9pGRrR6N4AkkX-L0DsBD4yNK3QRsQn3dB1fs3JRZPAh1yqUqTQYhOaqdggyc1EwL8FZHouGRkHTOcCmLQjyv6zuhi6CJbg&response=1&response=4&response=5&response=7' */ +/* +Response: +<!DOCTYPE HTML> +<html dir="ltr"> + <head> + <meta http-equiv="content-type" content="text/html; charset=UTF-8"> + <meta http-equiv="X-UA-Compatible" content="IE=edge"> + <title>reCAPTCHA challenge</title> + <link rel="stylesheet" href="https://www.gstatic.com/recaptcha/releases/0bBqi43w2fj-Lg1N3qzsqHNu/fallback__ltr.css" type="text/css" charset="utf-8"> + </head> + <body> + <div class="fbc"> + <div class="fbc-alert"></div> + <div class="fbc-header"> + <div class="fbc-logo"> + <div class="fbc-logo-img"></div> + <div class="fbc-logo-text">reCAPTCHA</div> + </div> + </div> + <div class="fbc-success"> + <div class="fbc-message">Copy this code and paste it in the empty box below</div> + <div class="fbc-verification-token"><textarea dir="ltr" readonly>03AOLTBLTgp-3_4rll3cj-7vPEuXf3I1T371oFiNjfvmu5XtyraKJis7dxiOMNJxIhgn4qHkxpo4SoEwZvQMq3QdK-CPj-Hlu_GbJ74qKw37QeMqOPGciWeFko53F_GLEh2XWjB2b83WTE2ecXXB2MKQAxVGR09VMxlencPojYU3gOTTPc3hhvMz42w0MBxwaisrocB29oL0zpNfWCwdQHjujeLM0C96_rroeprwSM-DI-3FcBJqinLjvJnLXIw47Uve84pn-VOIdR</textarea></div> + <script nonce="cP5blNrqx/Tso76NX9b4qw">document.getElementsByClassName("fbc-verification-token")[0].firstChild.onclick = function() {this.select();};</script> + <div class="fbc-message fbc-valid-time">This code is valid for 2 minutes</div> + </div> + <div class="fbc-separator"></div> + <div class="fbc-privacy"><a href="https://www.google.com/intl/en/policies/privacy/" target="_blank">Privacy</a> - <a href="https://www.google.com/intl/en/policies/terms/" target="_blank">Terms</a></div> + </div> + <script nonce="cP5blNrqx/Tso76NX9b4qw">document.body.className += " js-enabled";</script> + </body> +</html> +*/ /* Posting message: curl 'https://sys.4chan.org/bant/post' @@ -27,6 +61,249 @@ curl 'https://sys.4chan.org/bant/post' -H 'Cookie: __cfduid=d4bd4932e46bc3272fae4ce7a4e2aac511546800687; 4chan_pass=_SsBuZaATt3dIqfVEWlpemhU5XLQ6i9RC' --data-binary $'-----------------------------119561554312148213571335532670\r\nContent-Disposition: form-data; name="resto"\r\n\r\n8640736\r\n-----------------------------119561554312148213571335532670\r\nContent-Disposition: form-data; name="com"\r\n\r\n>>8640771\r\nShe looks finnish\r\n-----------------------------119561554312148213571335532670\r\nContent-Disposition: form-data; name="mode"\r\n\r\nregist\r\n-----------------------------119561554312148213571335532670\r\nContent-Disposition: form-data; name="pwd"\r\n\r\n_SsBuZaATt3dIqfVEWlpemhU5XLQ6i9RC\r\n-----------------------------119561554312148213571335532670\r\nContent-Disposition: form-data; name="g-recaptcha-response"\r\n\r\n03AOLTBLS5lshp5aPj5pG6xdVMQ0pHuHxAtJoCEYuPLNKYlsRWNCPQegjB9zgL-vwdGMzjcT-L9iW4bnQ5W3TqUWHOVqtsfnx9GipLUL9o2XbC6r9zy-EEiPde7l6J0WcZbr9nh_MGcUpKl6RGaZoYB3WwXaDq74N5hkmEAbqM_CBtbAVVlQyPmemI2HhO2J6K0yFVKBrBingtIZ6-oXBXZ4jC4rT0PeOuVaH_gf_EBjTpb55ueaPmTbeLGkBxD4-wL1qA8F8h0D8c\r\n-----------------------------119561554312148213571335532670--\r\n' */ +/* Response if banned: +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<meta name="robots" content="noarchive"> +<meta name="description" content=""/g/ - Technology" is 4chan's imageboard for discussing computer hardware and software, programming, and general technology."> +<meta name="keywords" content="imageboard,worksafe,computer,technology,hardware,software,microsoft,apple,pc,mobile,programming"> +<meta name="referrer" content="origin"> +<meta name="viewport" content="width=device-width,initial-scale=1"> + +<link rel="shortcut icon" href="//s.4cdn.org/image/favicon-ws.ico"> +<link rel="stylesheet" title="switch" href="//s.4cdn.org/css/yotsubluenew.692.css"><link rel="alternate stylesheet" style="text/css" href="//s.4cdn.org/css/yotsubanew.692.css" title="Yotsuba New"><link rel="alternate stylesheet" style="text/css" href="//s.4cdn.org/css/yotsubluenew.692.css" title="Yotsuba B New"><link rel="alternate stylesheet" style="text/css" href="//s.4cdn.org/css/futabanew.692.css" title="Futaba New"><link rel="alternate stylesheet" style="text/css" href="//s.4cdn.org/css/burichannew.692.css" title="Burichan New"><link rel="alternate stylesheet" style="text/css" href="//s.4cdn.org/css/photon.692.css" title="Photon"><link rel="alternate stylesheet" style="text/css" href="//s.4cdn.org/css/tomorrow.692.css" title="Tomorrow"><link rel="stylesheet" href="//s.4cdn.org/css/yotsubluemobile.692.css"><link rel="stylesheet" href="//s.4cdn.org/js/prettify/prettify.692.css"> +<link rel="canonical" href="http://boards.4channel.org/g/"> +<link rel="alternate" title="RSS feed" href="/g/index.rss" type="application/rss+xml"> +<title>/g/ - Technology - 4chan</title><script type="text/javascript"> +var style_group = "ws_style", +cssVersion = 692, +jsVersion = 1042, +comlen = 2000, +maxFilesize = 4194304, +maxLines = 100, +clickable_ids = 1, +cooldowns = {"thread":600,"reply":60,"image":60} +; +var maxWebmFilesize = 3145728;var board_archived = true;var check_for_block = 1;is_error = "true";</script><script type="text/javascript" data-cfasync="false" src="//s.4cdn.org/js/core.min.1042.js"></script> + +<noscript><style type="text/css">#postForm { display: table !important; }#g-recaptcha { display: none; }</style></noscript> +</head> +<body class="is_index board_g"> +<span id="id_css"></span> + +<div id="boardNavDesktop" class="desktop"> +<span class="boardList"> +[<a href="https://boards.4channel.org/a/" title="Anime & Manga">a</a> / +<span class="nwsb"><a href="//boards.4chan.org/b/" title="Random">b</a> / </span> +<a href="https://boards.4channel.org/c/" title="Anime/Cute">c</a> / +<span class="nwsb"><a href="//boards.4chan.org/d/" title="Hentai/Alternative">d</a> / </span> +<span class="nwsb"><a href="//boards.4chan.org/e/" title="Ecchi">e</a> / </span> +<span class="nwsb"><a href="//boards.4chan.org/f/" title="Flash">f</a> / </span> +<a href="https://boards.4channel.org/g/" title="Technology">g</a> / +<span class="nwsb"><a href="//boards.4chan.org/gif/" title="Adult GIF">gif</a> / </span> +<span class="nwsb"><a href="//boards.4chan.org/h/" title="Hentai">h</a> / </span> +<span class="nwsb"><a href="//boards.4chan.org/hr/" title="High Resolution">hr</a> / </span> +<a href="https://boards.4channel.org/k/" title="Weapons">k</a> / +<a href="https://boards.4channel.org/m/" title="Mecha">m</a> / +<a href="https://boards.4channel.org/o/" title="Auto">o</a> / +<a href="https://boards.4channel.org/p/" title="Photo">p</a> / +<span class="nwsb"><a href="//boards.4chan.org/r/" title="Adult Requests">r</a> / </span> +<span class="nwsb"><a href="//boards.4chan.org/s/" title="Sexy Beautiful Women">s</a> / </span> +<span class="nwsb"><a href="//boards.4chan.org/t/" title="Torrents">t</a> / </span> +<span class="nwsb"><a href="//boards.4chan.org/u/" title="Yuri">u</a> / </span> +<a href="https://boards.4channel.org/v/" title="Video Games">v</a> / +<a href="https://boards.4channel.org/vg/" title="Video Game Generals">vg</a> / +<a href="https://boards.4channel.org/vr/" title="Retro Games">vr</a> / +<a href="https://boards.4channel.org/w/" title="Anime/Wallpapers">w</a> +<span class="nwsb"> / <a href="//boards.4chan.org/wg/" title="Wallpapers/General">wg</a></span>] + +<span class="nwsb">[<a href="//boards.4chan.org/i/" title="Oekaki">i</a> / +<a href="https://boards.4channel.org/ic/" title="Artwork/Critique">ic</a>] </span> + +[<span class="nwsb"><a href="//boards.4chan.org/r9k/" title="ROBOT9001">r9k</a> / </span> +<span class="nwsb"><a href="//boards.4chan.org/s4s/" title="Shit 4chan Says">s4s</a> / </span> +<a href="https://boards.4channel.org/vip/" title="Very Important Posts">vip</a> / +<a href="https://boards.4channel.org/qa/" title="Question & Answer">qa</a>] + +[<a href="https://boards.4channel.org/cm/" title="Cute/Male">cm</a> / +<span class="nwsb"><a href="//boards.4chan.org/hm/" title="Handsome Men">hm</a> / </span> +<a href="https://boards.4channel.org/lgbt/" title="LGBT">lgbt</a> +<span class="nwsb"> / <a href="//boards.4chan.org/y/" title="Yaoi">y</a></span>] + +[<a href="https://boards.4channel.org/3/" title="3DCG">3</a> / +<span class="nwsb"><a href="//boards.4chan.org/aco/" title="Adult Cartoons">aco</a> / </span> +<a href="https://boards.4channel.org/adv/" title="Advice">adv</a> / +<a href="https://boards.4channel.org/an/" title="Animals & Nature">an</a> / +<a href="https://boards.4channel.org/asp/" title="Alternative Sports">asp</a> / +<span class="nwsb"><a href="//boards.4chan.org/bant/" title="International/Random">bant</a> / </span> +<a href="https://boards.4channel.org/biz/" title="Business & Finance">biz</a> / +<a href="https://boards.4channel.org/cgl/" title="Cosplay & EGL">cgl</a> / +<a href="https://boards.4channel.org/ck/" title="Food & Cooking">ck</a> / +<a href="https://boards.4channel.org/co/" title="Comics & Cartoons">co</a> / +<a href="https://boards.4channel.org/diy/" title="Do It Yourself">diy</a> / +<a href="https://boards.4channel.org/fa/" title="Fashion">fa</a> / +<a href="https://boards.4channel.org/fit/" title="Fitness">fit</a> / +<a href="https://boards.4channel.org/gd/" title="Graphic Design">gd</a> / +<span class="nwsb"><a href="//boards.4chan.org/hc/" title="Hardcore">hc</a> / </span> +<a href="https://boards.4channel.org/his/" title="History & Humanities">his</a> / +<a href="https://boards.4channel.org/int/" title="International">int</a> / +<a href="https://boards.4channel.org/jp/" title="Otaku Culture">jp</a> / +<a href="https://boards.4channel.org/lit/" title="Literature">lit</a> / +<a href="https://boards.4channel.org/mlp/" title="Pony">mlp</a> / +<a href="https://boards.4channel.org/mu/" title="Music">mu</a> / +<a href="https://boards.4channel.org/n/" title="Transportation">n</a> / +<a href="https://boards.4channel.org/news/" title="Current News">news</a> / +<a href="https://boards.4channel.org/out/" title="Outdoors">out</a> / +<a href="https://boards.4channel.org/po/" title="Papercraft & Origami">po</a> / +<span class="nwsb"><a href="//boards.4chan.org/pol/" title="Politically Incorrect">pol</a> / </span> +<a href="https://boards.4channel.org/qst/" title="Quests">qst</a> / +<a href="https://boards.4channel.org/sci/" title="Science & Math">sci</a> / +<span class="nwsb"><a href="//boards.4chan.org/soc/" title="Cams & Meetups">soc</a> / </span> +<a href="https://boards.4channel.org/sp/" title="Sports">sp</a> / +<a href="https://boards.4channel.org/tg/" title="Traditional Games">tg</a> / +<a href="https://boards.4channel.org/toy/" title="Toys">toy</a> / +<a href="https://boards.4channel.org/trv/" title="Travel">trv</a> / +<a href="https://boards.4channel.org/tv/" title="Television & Film">tv</a> / +<a href="https://boards.4channel.org/vp/" title="Pokémon">vp</a> / +<a href="https://boards.4channel.org/wsg/" title="Worksafe GIF">wsg</a> / +<a href="https://boards.4channel.org/wsr/" title="Worksafe Requests">wsr</a> / +<a href="https://boards.4channel.org/x/" title="Paranormal">x</a>] + +</span> + +<span id="navtopright">[<a href="javascript:void(0);" id="settingsWindowLink">Settings</a>] +[<a href="/search" title="Search">Search</a>] +[<a href="//p.4chan.org/" title="Mobile">Mobile</a>] +[<a href="//www.4channel.org/" target="_top">Home</a>]</span> +</div> + +<div id="boardNavMobile" class="mobile"> + <div class="boardSelect"> + <strong>Board</strong> + <select id="boardSelectMobile"></select> + </div> + + <div class="pageJump"> + <a href="#bottom">▼</a> + <a href="javascript:void(0);" id="settingsWindowLinkMobile">Settings</a> + <a href="//p.4chan.org/">Mobile</a> + <a href="//www.4channel.org" target="_top">Home</a> + </div> + +</div> + + +<div class="boardBanner"> + <div id="bannerCnt" class="title desktop" data-src="189.jpg"></div> + <div class="boardTitle">/g/ - Technology</div> + +</div> +<hr class="abovePostForm"><script type="text/javascript"> + setTimeout(function() { window.location = "https://www.4channel.org/banned"; }, 3000); +</script><table style="text-align: center; width: 100%; height: 300px;"><tr valign="middle"><td align="center" style="font-size: x-large; font-weight: bold;"><span id="errmsg" style="color: red;">Error: You are <a href="https://www.4channel.org/banned" target="_blank">banned</a>.</span><br><br>[<a href=//boards.4channel.org/g/>Return</a>]</td></tr></table><br><br><hr size=1><div id="absbot" class="absBotText"> + +<div class="mobile"> +<span id="disable-mobile">[<a href="javascript:disableMobile();">Disable Mobile View / Use Desktop Site</a>]<br><br></span> +<span id="enable-mobile">[<a href="javascript:enableMobile();">Enable Mobile View / Use Mobile Site</a>]<br><br></span> +</div> + +<span class="absBotDisclaimer"> +All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster. +</span> +<div id="footer-links"><a href="//www.4channel.org/faq#what4chan" target="_blank">About</a> • <a href="//www.4channel.org/feedback" target="_blank">Feedback</a> • <a href="//www.4channel.org/legal" target="_blank">Legal</a> • <a href="//www.4channel.org/contact" target="_blank">Contact</a></div> +</div> + +<div id="bottom"></div> +<script type="text/javascript" src="//s.4cdn.org/js/prettify/prettify.1042.js"></script><script type="text/javascript">prettyPrint();</script><script>var a= document.createElement('script');a.src = 'https://powerad.ai/script.js';a.setAttribute('async','');top.document.querySelector('head').appendChild(a);</script></body></html> +*/ +/* Banned page: +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> +<meta name="viewport" content="width=device-width, initial-scale=1.0"> +<meta name="keywords" content="imageboard,image board,forum,bbs,anonymous,chan,anime,manga,ecchi,hentai,video games,english,japan"> +<meta name="robots" content="noarchive"> +<title>4chan - Banned</title><link rel="stylesheet" type="text/css" href="//s.4cdn.org/css/yui.8.css"> +<link rel="stylesheet" type="text/css" href="//s.4cdn.org/css/global.61.css"> +<link rel="shortcut icon" href="//s.4cdn.org/image/favicon.ico"> +<link rel="apple-touch-icon" href="//s.4cdn.org/image/apple-touch-icon-iphone.png"> +<link rel="apple-touch-icon" sizes="72x72" href="//s.4cdn.org/image/apple-touch-icon-ipad.png"> +<link rel="apple-touch-icon" sizes="114x114" href="//s.4cdn.org/image/apple-touch-icon-iphone-retina.png"> +<link rel="apple-touch-icon" sizes="144x144" href="//s.4cdn.org/image/apple-touch-icon-ipad-retina.png"> +<link rel="stylesheet" type="text/css" href="//s.4cdn.org/css/banned.14.css"> +<script async="" src="//www.google-analytics.com/analytics.js"></script><script type="text/javascript">(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga'); +var tid = /(^|\.)4channel.org$/.test(location.host) ? 'UA-166538-5' : 'UA-166538-1'; +ga('create', tid, {'sampleRate': 1}); +ga('set', 'anonymizeIp', true); +ga('send','pageview')</script> +<script type="text/javascript" src="//s.4cdn.org/js/banned.14.js"></script> +<style type="text/css">#verify-btn { margin-top: 15px; }</style><style type="text/css">#quote-preview {display: block;position: absolute;padding: 3px 6px 6px 3px;margin: 0;text-align: left;border-width: 1px 2px 2px 1px;border-style: solid;}#quote-preview.nws {color: #800000;border-color: #D9BFB7;}#quote-preview.ws {color: #000;border-color: #B7C5D9;}#quote-preview.ws a {color: #34345C;}#quote-preview input {margin: 3px 3px 3px 4px;}.ws.reply {background-color: #D6DAF0;}.nws.reply {background-color: #F0E0D6;}.subject {font-weight: bold;}.ws .subject {color: #0F0C5D;}.nws .subject {color: #CC1105;}.quote {color: #789922;}.quotelink,.deadlink {color: #789922 !important;}.ws .useremail .postertrip,.ws .useremail .name {color: #34345C !important;}.nws .useremail .postertrip,.nws .useremail .name {color: #0000EE !important;}.nameBlock {display: inline-block;}.name {color: #117743;font-weight: bold;}.postertrip {color: #117743;font-weight: normal !important;}.postNum a {text-decoration: none;}.ws .postNum a {color: #000 !important;}.nws .postNum a {color: #800000 !important;}.fileInfo {margin-left: 20px;}.fileThumb {float: left;margin: 3px 20px 5px;}.fileThumb img {border: none;float: left;}s {background-color: #000000 !important;}.capcode {font-weight: bold !important;}.nameBlock.capcodeAdmin span.name, span.capcodeAdmin span.name a, span.capcodeAdmin span.postertrip, span.capcodeAdmin strong.capcode {color: #FF0000 !important;}.nameBlock.capcodeMod span.name, span.capcodeMod span.name a, span.capcodeMod span.postertrip, span.capcodeMod strong.capcode {color: #800080 !important;}.nameBlock.capcodeDeveloper span.name, span.capcodeDeveloper span.name a, span.capcodeDeveloper span.postertrip, span.capcodeDeveloper strong.capcode {color: #0000F0 !important;}.identityIcon {height: 16px;margin-bottom: -3px;width: 16px;}.postMessage {margin: 13px 40px 13px 40px;}.countryFlag {margin-bottom: -1px;padding-top: 1px;}.fileDeletedRes {height: 13px;width: 127px;}span.fileThumb, span.fileThumb img {float: none !important;margin-bottom: 0 !important;margin-top: 0 !important;}</style><style>#captcha-cnt { + height: auto; +} +:root:not(.js-enabled) #form { + display: block; +} +#bd > div[style], #bd > div[style] > * { + height: auto !important; + margin: 0 !important; + font-size: 0; +} +</style></head> +<body> +<div id="doc"> +<div id="hd"> +<div id="logo-fp"> +<a href="//www.4chan.org/" title="Home"><img alt="4chan" src="//s.4cdn.org/image/fp/logo-transparent.png" width="300" height="120"></a> +</div> +</div> +<div class="box-outer top-box"> +<div class="box-inner"> +<div class="boxbar"> +<h2>You are <span class="banType">banned</span>! ;_;</h2> +</div> +<div class="boxcontent"> +<img src="https://sys.4chan.org/image/error/banned/250/rid.php" alt="Banned" style="float: right; padding-left: 10px; min-height: 150px;" width="250"> +<script type="text/javascript">var banjson_0 = {"no":73505519,"now":"11\/09\/19(Sat)16:10:01","name":"Anonymous","com":"<span class=\"deadlink\">>>73505385<\/span><br>People like you are considered right-wing now, according to the left (since the left has gone futher left, they think everybody else has gone further right. There are studies on on political leaning over time that matches this)","id":"","board":"g","ws_board":1}</script> +You have been banned from <b class="board">/g/</b> for posting <a href="#" class="bannedPost_0">>>73505519</a>, a violation of <b>Rule 1</b>:<br><br> +<b class="reason">Off-topic; all images and discussion should pertain to technology and related topics.</b><br><br> +Your ban was filed on <b class="startDate">November 9th, 2019</b> and expires on <b class="endDate">November 10th, 2019 at 22:10 ET</b>, which is 23 hours and 14 minutes from now. +<br><br> +According to our server, your IP is: <b class="bannedIp">YOURIP</b>. The name you were posting with was <span class="nameBlock"><span class="name">Anonymous</span></span>.<br> +<br> +Because of the short length of your ban, you may not appeal it. Please check back when your ban has expired. +<br class="clear-bug"> +</div> +</div> +</div> +<div class="yui-g"> +<div class="yui-u first"> +</div><div class="yui-u"> +</div> +</div> +</div> +<div id="ft"><ul><li class="fill"> +</li><li class="first"><a href="/">Home</a></li> +<li><a href="/4channews.php">News</a></li> +<li><a href="http://blog.4chan.org/">Blog</a></li> +<li><a href="/faq">FAQ</a></li> +<li><a href="/rules">Rules</a></li> +<li><a href="/pass">Support 4chan</a></li> +<li><a href="/advertise">Advertise</a></li> +<li><a href="/press">Press</a></li> +<li><a href="/japanese">日本語</a></li> +</ul> +<br class="clear-bug"> +<div id="copyright"><a href="/faq#what4chan">About</a> • <a href="/feedback">Feedback</a> • <a href="/legal">Legal</a> • <a href="/contact">Contact</a><br><br><br> +Copyright © 2003-2019 4chan community support LLC. All rights reserved. +</div> +</div> + +<div id="modal-bg"></div> + + +</body> +*/ namespace QuickMedia { PluginResult Fourchan::get_front_page(BodyItems &result_items) { @@ -52,7 +329,7 @@ namespace QuickMedia { if(board_id.isString() && board_title.isString() && board_description.isString()) { std::string board_description_str = board_description.asString(); html_unescape_sequences(board_description_str); - auto body_item = std::make_unique<BodyItem>(board_title.asString()); + auto body_item = std::make_unique<BodyItem>("/" + board_id.asString() + "/ " + board_title.asString()); body_item->url = board_id.asString(); result_items.emplace_back(std::move(body_item)); } @@ -134,6 +411,94 @@ namespace QuickMedia { return PluginResult::OK; } + struct CommentPiece { + enum class Type { + TEXT, + QUOTE, // > + QUOTELINK, // >>POSTNO, + LINEBREAK + }; + + std::string_view text; // Set when type is TEXT, QUOTE or QUOTELINK + int64_t quote_postnumber; // Set when type is QUOTELINK + Type type; + }; + + static TidyAttr get_attribute_by_name(TidyNode node, const char *name) { + for(TidyAttr attr = tidyAttrFirst(node); attr; attr = tidyAttrNext(attr)) { + const char *attr_name = tidyAttrName(attr); + if(attr_name && strcmp(name, attr_name) == 0) + return attr; + } + return nullptr; + } + + static const char* get_attribute_value(TidyNode node, const char *name) { + TidyAttr attr = get_attribute_by_name(node, name); + if(attr) + return tidyAttrValue(attr); + return nullptr; + } + + using CommentPieceCallback = std::function<void(const CommentPiece&)>; + static void extract_comment_pieces(TidyDoc doc, TidyNode node, CommentPieceCallback callback) { + const char *node_name = tidyNodeGetName(node); + printf("node name: %s\n", node_name ? node_name : "N/A"); + + TidyNodeType node_type = tidyNodeGetType(node); + if(node_type == TidyNode_Text) { + TidyBuffer tidy_buffer; + tidyBufInit(&tidy_buffer); + if(tidyNodeGetText(doc, node, &tidy_buffer)) { + CommentPiece comment_piece; + comment_piece.type = CommentPiece::Type::TEXT; + if(node_name) { + if(strncmp("a", (const char*)tidy_buffer.bp, tidy_buffer.size) == 0) { + const char *a_href = get_attribute_value(node, "href"); + if(a_href && strncmp(a_href, "#p", 2) == 0) { + comment_piece.type = CommentPiece::Type::QUOTELINK; + comment_piece.quote_postnumber = strtoll(a_href + 2, nullptr, 10); + } + } else if(strncmp("span", (const char*)tidy_buffer.bp, tidy_buffer.size) == 0) { + const char *a_class = get_attribute_value(node, "class"); + if(a_class && strcmp(a_class, "quote") == 0) { + comment_piece.type = CommentPiece::Type::QUOTE; + comment_piece.text = { (const char*)tidy_buffer.bp, tidy_buffer.size }; + } + } + } + printf("Comment piece value: %.*s\n", tidy_buffer.size, tidy_buffer.bp); + comment_piece.text = { (const char*)tidy_buffer.bp, tidy_buffer.size }; + callback(comment_piece); + } + tidyBufFree(&tidy_buffer); + } else if(node_name) { + if(strcmp("br", node_name) == 0) { + CommentPiece comment_piece; + comment_piece.type = CommentPiece::Type::LINEBREAK; + callback(comment_piece); + } + } + + for(TidyNode child = tidyGetChild(node); child; child = tidyGetNext(child)) { + extract_comment_pieces(doc, child, callback); + } + } + + static void extract_comment_pieces(const char *html_source, size_t size, CommentPieceCallback callback) { + TidyDoc doc = tidyCreate(); + tidyOptSetBool(doc, TidyShowWarnings, no); + if(tidyParseString(doc, html_source) < 0) { + CommentPiece comment_piece; + comment_piece.type = CommentPiece::Type::TEXT; + comment_piece.text = { html_source, size }; + callback(comment_piece); + } else { + extract_comment_pieces(doc, tidyGetBody(doc), std::move(callback)); + } + tidyRelease(doc); + } + PluginResult Fourchan::get_content_details(const std::string &list_url, const std::string &url, BodyItems &result_items) { std::string server_response; if(download_to_string(fourchan_url + list_url + "/thread/" + url + ".json", server_response) != DownloadResult::OK) @@ -155,14 +520,35 @@ namespace QuickMedia { continue; const Json::Value &com = post["com"]; - if(!com.isString()) + const char *comment_begin; + const char *comment_end; + if(!com.getString(&comment_begin, &comment_end)) continue; const Json::Value &post_num = post["no"]; if(!post_num.isNumeric()) continue; - auto body_item = std::make_unique<BodyItem>(com.asString()); + std::string comment_text; + extract_comment_pieces(comment_begin, comment_end - comment_begin, [&comment_text](const CommentPiece &cp) { + switch(cp.type) { + case CommentPiece::Type::TEXT: + comment_text += cp.text; + break; + case CommentPiece::Type::QUOTE: + comment_text += '>'; + comment_text += cp.text; + break; + case CommentPiece::Type::QUOTELINK: + comment_text += cp.text; + break; + case CommentPiece::Type::LINEBREAK: + // comment_text += '\n'; + break; + } + }); + html_unescape_sequences(comment_text); + auto body_item = std::make_unique<BodyItem>(std::move(comment_text)); body_item->url = std::to_string(post_num.asInt64()); const Json::Value &ext = post["ext"]; |