My Odd Fix to Duplicate TV Episodes in Library
#1
I have no idea why this worked or if it would be useful to anyone else. But there have been a number of threads with problems just like mine (running 10.1 in Windows 7 using a mysql database rather than the built in db). I had no problem with my movies but about half of my TV episodes were coming up in the library doubled. I cleared the data base and re-installed any number of times, but I would watch the library update adding the shows the first time and then adding them again, and I would find each episode in the listings doubled.

Actually, only half were doubled. All the ones coming from one share were doubled, and all the others from a second share were not. It was frustrating. I would remove the "bad" share and one set of the episodes would remain. Then I would have to remove each show manually from the library (being careful to say no to removing the file). And then I would try to reconnect, but it would double again.

I looked for any differences I could find between the share that worked and the share that doubled. They were both on the same computer, but different drives. The only single difference I could find was the one that worked had a share name (e.g. smb://computer/TV2) that was difference from the actual folder name on that computer (e.g. z:/TV). When the shares are set up, by default they just take the folder name, but in that case I had a TV folder on both drives so the second one's share got named TV2 while the folder was TV.

I felt really stupid trying this, but I was desperate, so I took the share that was giving me problems and renamed the share different from the folder name. So when the folder was x:/TV, I named the share smb://computer/TV4 rather than smb://computer/TV.

Incredibly, this worked. I have no idea why. No doubling when the share was read into the library and I have updated the library a number of times since and it has not doubled. It is possible I simultaneously changed something else which really fixed it, but I don't think so. I had tried absolutely everything else I could think of before.

YMMV, but I offer this in case it helps someone else.
Reply
#2
Here was my fix. No warranties... backup your database if you're nervous or change 'delete ' to 'select * ' to see what would happen before actually performing the deletes.

This makes 3 views to help spot duplicate episodes or unlinked files (files that have no movie or episode associated with them). Then it deletes the duplicates using the views. It works correctly for 1 and 2 episode files (i.e., 1x01, 1x01-1x02 or 1x01-02), but it won't catch 1x01-1x03 or 1x01-1x04... if you have any 3+ episode files, I would advise against using this.

create or replace view duplicateepisodes as select max(e.idEpisode) idEpisode from tvshow s join tvshowlinkepisode se on s.idShow = se.idShow join episode e on se.idEpisode = e.idEpisode join files f on e.idFile = f.idFile group by f.strFilename having count(e.idEpisode) > case when f.strFilename regexp '[0-9]+x[0-9][0-9]-[0-9]+x[0-9][0-9]' then 2 when f.strFilename regexp '[0-9]+x[0-9][0-9]-[0-9][0-9]' then 2 else 1 end;
create or replace view duplicateepisodedetails as select s.idShow, s.c00 showName, e.idEpisode, e.c12 season, e.c13 episodeNumber, e.c00 episodeName, p.strPath path, f.strFilename fileName from duplicateepisodes de join episode e on de.idEpisode = e.idEpisode join tvshowlinkepisode se on e.idEpisode = se.idEpisode join tvshow s on se.idShow = s.idShow join files f on e.idFile = f.idFile join path p on f.idPath = p.idPath;
create or replace view unlinkedfiles as select idFile from files f where f.idFile not in (select idFile from episode) and f.idFile not in (select idFile from movie);
delete from tvshowlinkepisode where idEpisode in (select idEpisode from duplicateepisodes);
delete from episode where idEpisode in (select idEpisode from duplicateepisodes);
delete from files where idFile in (select idFile from unlinkedfiles);
Reply
#3
Note that the problem is simply due to having 2 distinct paths in the database that point to the same set of files. XBMC currently cannot detect this, so lists everything twice as if they're 2 distinct files.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#4
In my case these were exact duplicates. I was originally using using local paths on one machine and using redirection to SMB paths on the other machine. This was problematic. So I ended up changing the first machine to also use SMB paths, dropped both XMBC databases from XBMC and even deleted the XBMC datapath (essentially starting from scratch) and rebuilt the library. There seems to be something weird going on with MySQL support because I did get duplicates and they were literally identical filenames.

Is only one machine supposed to be updating the library? Maybe the second machine is updating the library as well and it's inserting the duplicates? It hasn't recurred since I ran the SQL above, but I'll post back if it does.
Reply
#5
when i do this,i get 2 title per movie..?..howcome,waht do i do wrong.?
Reply
#6
Probably you have 2 different paths to the same thing... do a settings>video>clean-up and see if you are clean, the issue is solved... If another subsequent scan brings multiple titles of the same thing, then look at your source listings, and each individual duplicate file in focus and check the path differences between the two.
Reply
#7
I get this same problem with TV shows, every time a show is scanned for new content or the entire library is updated many shows will get duplicated entries. There are no duplicate paths to the files and it's not consistant with any particular library path entry. If I go and change the content type to nothing (or change the scraper), clean the library, and then change it back the shows will be relisted properly, but another update, like one triggered by SickBeard or SabNZB, will result in duplicates again. this has resulted in a single show with a single season showing that it has 1500 episodes. If I go and mark one of the entries as watched then all of them get marked.

I've upgraded to the current build of Eden and still get the same results.
Reply
#8
It will almost certainly be different paths.

Check them in episode info for dupes - you'll notice they're different.

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#9
I've checked again and there's only 1 path to the files. I even went so far as to remove all paths and enter the 1 back in and I'm still getting some dupes. It's not all episodes within that path too, just some for some shows. I've also tried going in and removing anything but the mkv from within the folder but that doesn't change anything.

Possibly related but some shows list the correct number of episodes, but every single episode uses the same episode information as Ep1 (title, description, etc.) except for their thumbs (showing correct thumbnail for each episode). I was going to ask that as a different question but now I'm wondering if it's somehow related. Again I've cleared out any kind of .nfo or similar file from the series and season folders and had it re-scrape with no change in the results.

Very odd behavior.
Reply
#10
Pull up the info window for some of the dupes and compare the path string
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#11
Paths are identical. When I scan for updates and generate the duplicates it even marks the correct dupes as watched.

Again, this is all with 1 source. I've deleted all other source entries in my library. Files for those other sources are on completely different drives, but I don't want to take any chances while trying to troubleshoot this so I removed all but one content source.

I have a single entry, TV, that points to the path d:\tv. Structure is: d:\tv\mythbusters\season 10\(episode number and name).(ext)

Nothing fancy going on, so I'm not sure why this is happening. The repeating episodes and incorrectly-named/info episodes also show up that way in the web interface and thus on the XBMC Commander ipad app.

Maybe I should just delete the sql database and start over?
Reply
#12
(2012-02-15, 22:49)scottt732 Wrote: Is only one machine supposed to be updating the library?

Can anyone confirm the above Q? I'm getting duplicates as well and can't pinpoint why.
Reply
#13
This problem has been plaguing me too. There are no duplicate paths to the file (the filepath strings are identicial). Judging from all the other posts I can find, it always seems to stem from using a remote SQL database with sickbeard/sabnzbd.

This is a real problem and I think a lot of people would really appreciate some dev attention.

Here is the only (workaround) solution that I have found: http://forum.xbmc.org/showthread.php?tid...=duplicate
From what I have seen, it seems like a bug. Everyone appears to have everything set up correctly, but gets unexpected behavior.

I know my way around the logs, and I can post whatever the devs need me to in order to get this solved.
Reply
#14
You need to look in your database and grab out the idFile and idPath (from the files table), strFileName and strPath for each duplicate item.

Somewhere they'll be different. This is your problem.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#15
Threads merged, my next move was to ask what dev you lot demanded to look into this. But you are in luck. one found you.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply

Logout Mark Read Team Forum Stats Members Help
My Odd Fix to Duplicate TV Episodes in Library2