Duplicate channels in sqlite db, best way to fix?

Have a MythTV related problem? Ask for help from other MythTV users here.

Moderator: Forum Moderators

Post Reply
wmorrison
Senior
Posts: 165
Joined: Sat Dec 01, 2018 12:05 am
United States of America

Duplicate channels in sqlite db, best way to fix?

Post by wmorrison »

I use tv_grab_zz_sdjson_sqlite. I notice there are about four duplicate channels. mythfilldatabase.log shows they are skipped as 'Unknown xmltv channel identifier.'

Any idea how this could happen? Is the data coming duplicated from SchedulesDirect, or could it be "old channel" info that didn't get cleaned up? Is there a way to reinitialize the sqlite db without "breaking" it?

It's not causing a real problem, but I have some channel scans to do soon (new channel on-the-air but not in SD data yet, and several subchannels changed networks) so I might as well fix this if possible, while I'm at it.
User avatar
pgbennett
Developer
Posts: 503
Joined: Mon Apr 27, 2015 5:41 pm
United States of America

Re: Duplicate channels in sqlite db, best way to fix?

Post by pgbennett »

It sounds like you have some channels selected in sqlite that are not in your MythTV database. You can deselect them with sqlite.
Locate the sqlite database, it will be called SchedulesDirect.DB or similar, in your .xmltv directory or possibly somewhere in the .mythtv directory.

sqlite3 SchedulesDirect.DB
select * from channels;

In the channel table, set selected to 0 for those you do not want. Example:

update channels set selected = 0
where channum+0 >= 300 and channum+0 <= 336;

Note: I use the "+0" syntax to force a numeric check, otherwise it may regard channel 31 as being between 300 and 336.
wmorrison
Senior
Posts: 165
Joined: Sat Dec 01, 2018 12:05 am
United States of America

Re: Duplicate channels in sqlite db, best way to fix?

Post by wmorrison »

When I say duplicate, I don't just mean "same network," I mean actual duplicates in sqlite SchedulesDirect.DB with the same channum, atscMajor, atscMinor, uhfVhf, but different station (id.) I know how to deselect them but I don't know how it happened and want to know how to clean up the sd database.
wmorrison
Senior
Posts: 165
Joined: Sat Dec 01, 2018 12:05 am
United States of America

Re: Duplicate channels in sqlite db, best way to fix?

Post by wmorrison »

Well, the duplicates are from SD itself. I just set up a new database as a test (different directory and config, so it's "clean") and the duplicates are there. In fact besides the duplicate channel numbers, it also has some pre-repack channels with the old channel numbers. So I guess it doesn't cause any harm.
Post Reply