emacs/var/elfeed/db/data/9d/9d9b288f283d372dc69780de8cd111cdbe65cf27
2022-01-03 12:49:32 -06:00

40 lines
5.6 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>Using an RSS reader instead of visiting Youtube or other social media has many advantages, including that you have to deal with much less energy-sapping, will-eroding clickbait. Unfortunately feed entries can still have clickbaity titles that can DESTROY your patience! So I wrote a dumb-as-rocks declickbaiter for Elfeed. You WONT BELIEVE the results!</p>
<p>The Before (The After will SHOCK you!):
<img alt="" src="https://karthinks.com/img/declickbait-before-extra.png" /></p>
<p>The After:
<img alt="" src="https://karthinks.com/img/declickbait-after-extra.png" /></p>
<p>The Code:</p>
<div class="highlight"><pre><code class="language-emacs-lisp">(<span style="color: #b8860b;">add-hook</span> <span style="color: #b8860b;">'elfeed-new-entry-hook</span> <span style="color: #00a000;">#'</span><span style="color: #b8860b;">elfeed-declickbait-entry</span>)
(<span style="color: #a2f;">defun</span> <span style="color: #b8860b;">elfeed-declickbait-entry</span> (<span style="color: #b8860b;">entry</span>)
(<span style="color: #a2f;">let</span> ((<span style="color: #b8860b;">title</span> (<span style="color: #b8860b;">elfeed-entry-title</span> <span style="color: #b8860b;">entry</span>)))
(<span style="color: #a2f;">setf</span> (<span style="color: #b8860b;">elfeed-meta</span> <span style="color: #b8860b;">entry</span> <span style="color: #a2f;">:title</span>)
(<span style="color: #b8860b;">elfeed-title-transform</span> <span style="color: #b8860b;">title</span>))))
(<span style="color: #a2f;">defun</span> <span style="color: #b8860b;">elfeed-title-transform</span> (<span style="color: #b8860b;">title</span>)
<span style="color: #b44;">"Declickbait string TITLE."</span>
(<span style="color: #a2f;">let*</span> ((<span style="color: #b8860b;">trim</span> <span style="color: #b44;">"\\(?:\\(?:\\.\\.\\.\\|[!?]\\)+\\)"</span>)
(<span style="color: #b8860b;">arr</span> (<span style="color: #b8860b;">split-string</span> <span style="color: #b8860b;">title</span> <span style="color: #800;">nil</span> <span style="color: #800;">t</span> <span style="color: #b8860b;">trim</span>))
(<span style="color: #b8860b;">s-table</span> (<span style="color: #00a000;">copy-syntax-table</span>)))
(<span style="color: #00a000;">modify-syntax-entry</span> <span style="color: #b44;">?\'</span> <span style="color: #b44;">"w"</span> <span style="color: #b8860b;">s-table</span>)
(<span style="color: #a2f;">with-syntax-table</span> <span style="color: #b8860b;">s-table</span>
(<span style="color: #00a000;">mapconcat</span> (<span style="color: #a2f;">lambda</span> (<span style="color: #b8860b;">word</span>)
(<span style="color: #a2f;">cond</span>
((<span style="color: #00a000;">member</span> <span style="color: #b8860b;">word</span> <span style="color: #666;">'</span>(<span style="color: #b44;">"AND"</span> <span style="color: #b44;">"OR"</span> <span style="color: #b44;">"IF"</span> <span style="color: #b44;">"ON"</span> <span style="color: #b44;">"IT"</span> <span style="color: #b44;">"TO"</span>
<span style="color: #b44;">"A"</span> <span style="color: #b44;">"OF"</span> <span style="color: #b44;">"VS"</span> <span style="color: #b44;">"IN"</span> <span style="color: #b44;">"FOR"</span> <span style="color: #b44;">"WAS"</span>
<span style="color: #b44;">"IS"</span> <span style="color: #b44;">"BE"</span>))
(<span style="color: #00a000;">downcase</span> <span style="color: #b8860b;">word</span>))
((<span style="color: #00a000;">member</span> <span style="color: #b8860b;">word</span> <span style="color: #666;">'</span>(<span style="color: #b44;">"WE"</span> <span style="color: #b44;">"DAY"</span> <span style="color: #b44;">"HOW"</span> <span style="color: #b44;">"WHY"</span> <span style="color: #b44;">"NOW"</span> <span style="color: #b44;">"OLD"</span>
<span style="color: #b44;">"NEW"</span> <span style="color: #b44;">"MY"</span> <span style="color: #b44;">"TOO"</span> <span style="color: #b44;">"GOT"</span> <span style="color: #b44;">"GET"</span> <span style="color: #b44;">"THE"</span>
<span style="color: #b44;">"ONE"</span> <span style="color: #b44;">"DO"</span> <span style="color: #b44;">"YOU"</span>))
(<span style="color: #00a000;">capitalize</span> <span style="color: #b8860b;">word</span>))
((<span style="color: #00a000;">&gt;</span> (<span style="color: #00a000;">length</span> <span style="color: #b8860b;">word</span>) <span style="color: #666;">3</span>) (<span style="color: #00a000;">capitalize</span> <span style="color: #b8860b;">word</span>))
(<span style="color: #800;">t</span> <span style="color: #b8860b;">word</span>)))
<span style="color: #b8860b;">arr</span> <span style="color: #b44;">" "</span>))))
</code></pre></div><p><code>elfeed-title-transform</code> can be replaced with something much better, like a grammar aware title formatter (AI or otherwise), or with information extracted from the content or video description of the entry. But Ill settle for this pareto solution for what was <a href="https://youtube.com/watch?v=tF4OdtSuXMg">half an hour of live coding</a> in the dark:</p>
<p>Okay, the above screenshots were chosen as a joke. Heres a more representative version of the declickbait effect:</p>
<p>Before:
<img alt="" src="https://karthinks.com/img/declickbait-before.png" /></p>
<p>After:
<img alt="" src="https://karthinks.com/img/declickbait-after.png" /></p>