Remove Tags Via SQL Command?
#1
Hi All,

I run my system with a SQL backend. With the implementation of adding tags by default with scraping, I now have thousands of, for lack of a better word, useless tags. It's so overwhelming that it makes navigating to my own tags extremely time consuming.

Removing the tags within Kodi is time consuming to the point of it being impractical to do so with thousands of tags. Having to go into each individual tag and remove every item manually . . . Talking about probably 10000+ "clicks" to do it.

So, what I'm hoping to do is to remove Tags directly from the SQL backend but I don't want to go down this road if it's going to kill my database.

Thoughts appreciated.
Reply
#2
Tags are stored in the tag (tag name) and tag_link (link with a movie, show, ...) tables.
As long as the referential integrity is not broken between those two tables, the database shouldn't be corrupted.
But backups provide peace of mind.
Always read the Kodi online-manual, the FAQ and search the forum before posting.
Do not e-mail Kodi Team members directly asking for support. Read/follow the forum rules (wiki).
For troubleshooting and bug reporting please make sure you read this first.
Reply
#3
If there are questions of database integrity you are welcome to use the Kodi Selective Cleaner tool.  It is designed just for this using the video database analyzer feature. 

When I think about your question, what I am wondering is how can you tell the difference between the tags you want to keep vs. delete ?   That question would need to be answer before determining a programmatic way of bulk deleting the unwanted tags.  If you only had a few tags you wanted to keep and a bunch you wanted to delete then you could delete all tags and just add back the few you want to keep. 

Depending upon the answers there are a couple of ways to accomplish this without 10,000+ button clicks.


Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply
#4
(2024-05-05, 16:57)jrubenol Wrote: Hi All,

I run my system with a SQL backend. With the implementation of adding tags by default with scraping, I now have thousands of, for lack of a better word, useless tags. It's so overwhelming that it makes navigating to my own tags extremely time consuming.

Removing the tags within Kodi is time consuming to the point of it being impractical to do so with thousands of tags. Having to go into each individual tag and remove every item manually . . . Talking about probably 10000+ "clicks" to do it.

So, what I'm hoping to do is to remove Tags directly from the SQL backend but I don't want to go down this road if it's going to kill my database.

Thoughts appreciated.

I don't think the database implementation is particularly relevant. Unless something unusual is going on, it's not like this option became enabled out of the blue, and you're suddenly finding your collection of manually entered tags overwhelmed by the ocean of useless downloaded ones. Thus, if you just created a new database, delete it, disable the option, and start over. Been there, done that, and I doubt I will forget to check again. Starting over also solves the problem of distinguishing wanted from unwanted tags.

It's a mystery for the ages why leaving this option enabled continues to be the default. People who care about tags have been complaining about it for years. Does anybody find the default behavior useful?
Reply
#5
Hi All -

To each of you, thank you.

individual response: CrystalP and jbinkley60: Appreciate the input and will try to purge. As far as identifying, recreating is a possibility (in fact true that I only have about 5-10 useful tags and about 2200 useless ones. But I'm actually fine just typing up a list of the useless ones and going one by one if I can purge the entire tag without having to first remove items one by one. This at least makes it a 2190 deletion project instead of a 10,000+ deletion process.

Crawfish: Also considered just starting from scratch but it took me a long time to clean my db and make it perfect with the number of items that I have. The last time I purged was a few years back and honestly, it took months to go one by one and ensure that every item was scraped right, had the art that I wanted to use, ratings seemed sane, etc.... doing that again....sounds like more work than just keeping a couple thousand useless tags. I agree 100% that the default option being to pull the tags is insanity, who wants to base their tags on some other randos ideas of what deserves to be tagged?! The number of tags that I have that are: (1) entirely inappropriate; (2) repetitive; and (3) have a single item or two, is just proof that people don't know how to use tags appropriately and now we're stuck by default using their insanity.
Reply
#6
(2024-05-10, 15:53)jrubenol Wrote: Hi All -

To each of you, thank you.

individual response: CrystalP and jbinkley60: Appreciate the input and will try to purge. As far as identifying, recreating is a possibility (in fact true that I only have about 5-10 useful tags and about 2200 useless ones. But I'm actually fine just typing up a list of the useless ones and going one by one if I can purge the entire tag without having to first remove items one by one. This at least makes it a 2190 deletion project instead of a 10,000+ deletion process.

Crawfish: Also considered just starting from scratch but it took me a long time to clean my db and make it perfect with the number of items that I have. The last time I purged was a few years back and honestly, it took months to go one by one and ensure that every item was scraped right, had the art that I wanted to use, ratings seemed sane, etc.... doing that again....sounds like more work than just keeping a couple thousand useless tags. I agree 100% that the default option being to pull the tags is insanity, who wants to base their tags on some other randos ideas of what deserves to be tagged?! The number of tags that I have that are: (1) entirely inappropriate; (2) repetitive; and (3) have a single item or two, is just proof that people don't know how to use tags appropriately and now we're stuck by default using their insanity.

If you want I could create a special build of the Kodi Selective Cleaner addon which would have a button to clear the entries in your tag and tag-Link tables or since you are running My SQL you can issue the following commands from the query console to delete all of the current tags.  make sure you do a backup first but this should be fine if you want to delete all tags.

use your_database_name;
select * from tag

If you get the table contents then you can do:

use your_database_name;
delete * from tag

If this works do the same thing for the tag_link table:

use your_database_name;
select * from tag_link

If you get the table contents then you can do:

use your_database_name;
delete * from tag_link


Thanks,

Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply
#7
There is an in-between, if you want to keep only a few tags, then make the database engine work for you to remove everything else.

Identify the list of tag_id values that you want to keep with a query like this for each tag "select tag_id from tag where name = 'the text of the tag to preserve' " - or use a front end to visualize the table.

Then "delete from tag where tag_id not in ( tag_id#1, tag_id#2, tag_id#3)" obviously replacing the tag_id#1 etc with the actual tag_id values from the first query, and add as many tag_id as you need, separated with commas.
Finally "delete from tag_link where tag_id not in ( tag_id_1, tag_id_2, tag_id_3)" same deal as previous query to build the list of tag_id.
It's best to backup first, especially if you're not comfortable with the SQL language.
Always read the Kodi online-manual, the FAQ and search the forum before posting.
Do not e-mail Kodi Team members directly asking for support. Read/follow the forum rules (wiki).
For troubleshooting and bug reporting please make sure you read this first.
Reply

Logout Mark Read Team Forum Stats Members Help
Remove Tags Via SQL Command?0