ajkis / scripts

Ajki's scripts & guides
https://ajkis.github.io/scripts/
324 stars 91 forks source link

plex stats and analyze and analyze deeply #11

Open deliverer33 opened 7 years ago

deliverer33 commented 7 years ago

I've been using plex stats to see I have media missing analysis information. Even after I run both analyze scripts, it shows the same amount of objects missing data. Am I doing something wrong? Do I need to shutdown plex first before running?

5127 files in library 1141 files missing analyzation info 0 media_parts marked as deleted 0 metadata_items marked as deleted 0 directories marked as deleted 1365 files missing deep analyzation info.

ajkis commented 7 years ago

What does the analyze log say, can you get one id and try to analyze it manually.

deliverer33 commented 7 years ago

Unless I'm missing something there is no log output for the plex-analyze.cli or analyzedeeply.cli scripts?

deliverer33 commented 7 years ago

Also, I'm running this every 2 hours with the following cronjob. The files missing analyzation info are not declining. I'm running on Ubuntu and the default paths in the script are correct. Any ideas? I also hit you up on discord.

0 0,2,4,6,8,10,12,14,16,18,20,22 * /home/plex/scripts/plex-analyze.cli >/dev/null 2>$1

deliverer33 commented 7 years ago

Just to be clear is this telling plex to analyze files during the next scheduled maintenance window?

Animosity022 commented 7 years ago

I've found the analyze curl to run a lot faster than the cli one. I guess YMMV though.

It enumerates a list of everything that has to be analyzed and then analyzes it.

The "-a" says to analyze it and the "-o" is the item to analyze.

Try running it via a shell as your cron command would not provide any output as you are dropping all the output into /dev/null.

I get something like this when I run the curl item and I can see the analyze count down:

plex@plex:/home/plex/scripts/plex$ ./plex-analyze.curl
To analyze: 2609
4969
4969
4969
4970
4970

I did about 1000 over night in about an 6-7 hour window.

deliverer33 commented 7 years ago

I have the same issue where it looks at show three times. It led me to believe my database was corrupt so I completely reinstalled Plex. This first time I run the script it analyzes each file once, but upon future scans it does each one three times and the count for media analyzed never declines.

Animosity022 commented 7 years ago

I'm not sure what you mean, mine definitely is analyzing and the numbers are declining.

18256 files in library
2593 files missing analyzation info

after a few minutes

18256 files in library
2581 files missing analyzation info

You should remove your cronjob until you get completely caught up and then you can schedule it via cron as you'll only have a few to analyze. I would guess you are running multiple copies over and over again which may be problematic.

deliverer33 commented 7 years ago

I have removed it from cron. I'll post some details here later. My output looks similar to yours, but the count doesn't decline. If you let the script complete, is your count 0 at the end of files missing analyzation?

Animosity022 commented 7 years ago

It takes quite some time to analyze 4-5k files on ACD. I won't hit 0 until tomorrow probably.

You can see the count drop. You should see in your plex activity log to: http://i.imgur.com/A4Awdc3.png

I'd suggest just using the curl instead and drop your plex token in there. Seems much faster.

Animosity022 commented 7 years ago

I think I understand your question a bit better now. I let the analyze run for some time and it seems to have finished, but I have this left after I rerun it:

18259 files in library
1977 files missing analyzation info

I pulled up one of the IDs that seemed to show up as not having a bitrate:

http://i.imgur.com/VUOKzLO.png

I can't figure out how to tie that back to an actual file or show though.

@ajkis - any thoughts as I think that is probably @deliverer33 's question as well.

deliverer33 commented 7 years ago

@animosity22 exactly you got it! This it the problem I'm having. I'm running deep analyze now to see if it has the same issue, but it might take several days to complete.

sennico commented 7 years ago

I'm seeing a similar issue as @deliverer33 and @animosity22 using analyze. Analyze deeply seems to be lowering the count when i check plex stats

hjone72 commented 7 years ago

This is because it is trying to analyze an "extra" not an actual file.

hjone72 commented 7 years ago

Have a look at my pull request above. This should fix your issue.

deliverer33 commented 7 years ago

@hjone72 thanks. I'm testing now. Does the plex analyzedeeply.cli need to be updated as well to fix this? I'm currently running it, but it's going to take a few more days.

Can you run this and analyze deeply at same time?

hjone72 commented 7 years ago

I haven't had a look at deeply yet. Give me a half hour. Making a few changes to the scripts. I'll post them shortly.

deliverer33 commented 7 years ago

@hjone72 can I run both analyze scripts at same time? Anyone know?

hjone72 commented 7 years ago

Deep and normal? I wouldn't suggest it but nothing is stopping you. To be honest I don't think deep analysis has many benefits.

Animosity022 commented 7 years ago

What's is metadata type 12? Is that non video stuff?

hjone72 commented 7 years ago

It is the extras that Plex pulls for your movies and tv shows.

Animosity022 commented 7 years ago

So the library stats would be fixed with

query="select count(*) From media_items Inner Join metadata_items On media_items.metadata_item_id = metadata_items.id Where media_items.bitrate Is Null And Not metadata_items.metadata_type = 12"

I ran that and it removes all the extra items. Nice find!

hjone72 commented 7 years ago

Sorry, I haven't looked at those statistics scripts.

deliverer33 commented 7 years ago

@hjone72 I tested your new changes. It runs super fast. But I ran it twice and nothing changes?

plex@media ~/scripts $ ./plex-analyze.cli.py There are 36 files that need to be analyzed. Going to analyze the following ID's: 12,72,73,95,117,128,177,186,188,191,193,236,273,300,324,336,382,387,408,428,468,511,512,515,530,537,583,588,675,770,818,838,856,937,938,2795 Input items are: 12,72,73,95,117,128,177,186,188,191,193,236,273,300,324,336,382,387,408,428,468,511,512,515,530,537,583,588,675,770,818,838,856,937,938,2795 Finished analyzing all items.

plex@media ~/scripts $ ./plex-analyze.cli.py There are 36 files that need to be analyzed. Going to analyze the following ID's: 12,72,73,95,117,128,177,186,188,191,193,236,273,300,324,336,382,387,408,428,468,511,512,515,530,537,583,588,675,770,818,838,856,937,938,2795 Input items are: 12,72,73,95,117,128,177,186,188,191,193,236,273,300,324,336,382,387,408,428,468,511,512,515,530,537,583,588,675,770,818,838,856,937,938,2795

hjone72 commented 7 years ago

@deliverer33, Could you have a look at some of those items and tell me what they are?

for reference this is what the output should look like.

There are 36 files that need to be analyzed.
Going to analyze the following ID's: 12,72,73,95,117,128,177,186,188,191,193,236,273,300,324,336,382,387,408,428,468,511,512,515,530,537,583,588,675,770,818,838,856,937,938,2795
Input items are: 12,72,73,95,117,128,177,186,188,191,193,236,273,300,324,336,382,387,408,428,468,511,512,515,530,537,583,588,675,770,818,838,856,937,938,2795
GUI: Media analysis on Marvel's Agents of S.H.I.E.L.D. S02 E21
GUI:
GUI: Media analysis on Marvel's Agents of S.H.I.E.L.D. S02 E22
GUI:
GUI: Media analysis on All in Time
GUI:
GUI: Media analysis on A Very Murray Christmas
GUI:
GUI: Media analysis on Baby, Baby, Baby
GUI:
GUI: Media analysis on Mr. Woodcock
GUI:
GUI: Media analysis on Charmed S06 E22
GUI:
GUI: Media analysis on NBA S1516 E1701242274
GUI:
GUI: Media analysis on Doctor Strange
GUI:
Finished analyzing all items.
deliverer33 commented 7 years ago

@hjone72 Here are two examples, ID12 and ID408

ID12 `This XML file does not appear to have any style information associated with it. The document tree is shown below.

` ID408 `This XML file does not appear to have any style information associated with it. The document tree is shown below. `
deliverer33 commented 7 years ago

@hjone72 for the reanalyeItem.sh script I didn't change anything. All my directories are the default as the scripts reference and I'm running Ubuntu 16.04. Was I supposed to change anything in this script?

hjone72 commented 7 years ago

@deliverer33, Just reading through the above info now. You shouldn't have to change anything in reanalyeItem.sh unless your paths are different, which as you stated they aren't.

hjone72 commented 7 years ago

@deliverer33, Could you please confirm that when you press play on one of the affected files your player looks like this?

image

If they do... I have a few files doing something similar. Every time I 'Analyze' them, including through the web interface, they never collect the information (bitrate, etc). When I play them they look like the image above. I think there is something wrong with those specific files...

deliverer33 commented 7 years ago

@hjone72 when I attempted to play the two examples, Plex said they could not play them. I then clicked Analyze on both of them. After they were analyzed, they played fine. I then ran the script again, and they were no longer on it.

here is the complete output of the script. To me it's like it's identifying what needs to be analyzed, but not taking the next step.

There are 34 files that need to be analyzed. Going to analyze the following ID's: 72,73,95,117,128,177,186,188,191,193,236,273,300,324,336,382,387,428,468,511,512,515,530,537,583,588,675,770,818,838,856,937,938,2795 Input items are: 72,73,95,117,128,177,186,188,191,193,236,273,300,324,336,382,387,428,468,511,512,515,530,537,583,588,675,770,818,838,856,937,938,2795 Finished analyzing all items.

hjone72 commented 7 years ago

@deliverer33, Ahhh! I think I found the issue. Make the changes from this commit https://github.com/ajkis/scripts/pull/18/commits/bd559c86e56b573a34f1f294150037fdec976f15

deliverer33 commented 7 years ago

@hjone72 you are a rock star! I'm down to 3 shows now and I can confirm they are corrupt. Now we just need @ajkis to fix the plexlibrarystats to correctly reflect the right information.

hjone72 commented 7 years ago

@deliverer33, what is wrong with the library stats? Is it this issue here https://github.com/ajkis/scripts/issues/11#issuecomment-295985868?

deliverer33 commented 7 years ago

@hjone72 exactly. I took a chance and just guessed where that fix should go and now it displays 0 when ran. I'm ok with linux, but not a guru by any means.

hjone72 commented 7 years ago

@deliverer33 I'm not really sure what the point of the library stats is and I'm not running this script myself. Have a go with these changes. https://github.com/hjone72/plexScripts/commit/323cce42a726cc485f7414b72b3bdec056b68d3b