Plugin to remove article tags on feed import

I’m looking for a plugin to remove article tags on import and came across the following: aschilling / af_drop_categories, however it hasn’t been updated since 2014. Would anyone know if this would still work with the current version?

If it helps, I’ve pasted the code below:

init.php
<?php

/**

  • TT-RSS Plugin which removes category tags of a feed.
    */
    class Af_Drop_Categories extends Plugin {

      private $host;
    
      function about() {
              return array("0.1",
                      "Removes category tags from every feed.",
                      "aschilling");
      }
    
      function init($host) {
              $this->host = $host;
              $host->add_hook($host::HOOK_FEED_FETCHED, $this);
      }
    
      /**
    
  • After the feed is fetched, clean the category tags from $feed_data.
    /
    function hook_feed_fetched($feed_data, $fetch_url, $owner_uid, $feed) {
    _debug(“category_cleaner: Removing category tags”);
    $feed_data_cleaned = preg_replace("/(<category.
    ?<\/category>)/“, “”, $feed_data);
    $feed_data_cleaned = preg_replace(”/(<category.*?\/>)/", “”, $feed_data_cleaned);
    return $feed_data_cleaned;
    }

      function api_version() {
              return 2;
      }
    

}
?>

I remove all article tags from all feeds. It seemed like overkill to write a plugin for this.
I accomplish it by changing 1 character in classes/rssutils.php

find:
// Save article tags in the database

if (count($filtered_tags) > 0) {

change it to:
if (count($filtered_tags) < 0) { # don’t store any tags

Yeah, it’s a hack, but it couldn’t be more simple. It should be very unlikely to conflict with future updates.

Thanks for that! I was really hoping to find a plugin that would allow me to use on individual feeds, perhaps even with a filter. I might have to find some time over the holidays to roll up my sleeves and learn how to do it myself. In the meantime, I’ll probably have to use your method.

I did check out the filter in my first message and it was NOT working with the current version.

Use a filter to assign the article tag: noTags

Back in rssutils.php:

	// Save article tags in the database, maybe
	if (in_array('noTags', $filtered_tags)) 
      $filtered_tags = array();  # don't store this article's tags
	if (count($filtered_tags) > 0) {

Thanks for that. I’ll give it a shot!

What do you think of this modification to your idea? Instead of removing all the tags, let’s say I only want to remove specific tags. So, I create a filter to assign the tag ‘remove-badtag’ (where ‘badtag’ is the tag I want removed. Then, I add the following to rssutils.php?

// Save article tags in the database, except ones I want removed
if (in_array('remove-badtag', $filtered_tags))
	if (($tagkey = array_search('remove-badtag', $filtered_tags)) !== false) {
		unset($filtered_tags[$tagkey]);

		if (($tagkey = array_search('badtag', $filtered_tags)) !== false) {
		unset($filtered_tags[$tagkey]);
		}
	}
}

if (count($filtered_tags) > 0) {

I’ll take a closer look at your suggestion. Did you know there’s a tag blacklist in Preferences under Advanced?

Blacklisted tags:
main, generic, misc, uncategorized, blog, blogroll, general, new
Never apply these tags automatically (comma-separated list).

They apply to all feeds, but does that meet your need?

Yes, but I’m apparently not intelligent enough to figure out how to use it and I couldn’t find anything online to explain its usefulness . No matter how I tried to use it, I couldn’t make it block a tag on an incoming feed.

If I knew a year ago what I know now, I would have simply applied a more unique tag to incoming articles based on my criteria. Unfortunately, many of the feeds I’ve added recently apply the tag I’ve been using for a year and it messes with several filters I have in place. Since I have over 75 filters with many filters having 20-30 criteria, it gets messy trying to work backwards.

Try this.
Add “past day,past hour” to Blacklisted tags.

Subscribe to this feed:
https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_day.atom

After the initial update, if your update interval is 1 hour or less, all entries will come in with those 2 tags. The blacklist should remove them.

Thanks for testing.

You’ve probably seen already, but fox fixed the Blacklist Tags function and now that it’s working properly I think I can use that to get around the issues I’ve been experiencing. Thanks for sharing your thoughts and ideas to help me with a work-around.