Debugging a scanner

How do you debug a scanner?

 

Ive tried

   Log.Debug('asdfasfdasdf')

   Log('asdfasfdasdf')

   

Both breaks the scanner and in the Plex Media scanner.log this appears:

 

NameError: global name 'Log' is not defined

 

I've also tried

 

print('asdfasfdasdf')

 

Which doesnt break anything but I cant find the output in any logs.

 

best

Jesper

 

ps. OSX

The Scanner does not run under the same plugin framework as everything else so ("Log()" won't work in that context).  The best way to debug is probably to run the scanner from the command line and use regular print statements or logging as you already tried.

Here's some more info on how to do that: https://plexapp.zendesk.com/hc/en-us/articles/201242707-Plex-Media-Scanner-via-Command-Line

Here's how to run a scan script under the command line:

1. Change to the directory where the scan script is saved

$ cd /home/plex/Library/Application Support/Plex Media Server/Scanners/Movies/

2.  Run the scan script with the library path set

$ PYTHONPATH=/var/lib/plexmediaserver/Resources/Plug-ins/Scanners.bundle/Contents/Resources/Common python2 Plex\ Series\ Scanner\ \(with\ disc\ image\ support\).py /path/to/test/with/scanner

Make sure not to put a trailing slash on the /path/to/test/with/scanner ! (i.e. don't do /path/to/test/with/scanner/ )

In the case of the Series scanner, I had to cut the __main__ code and post it at the end so it could find all the functions.  Haven't gotten my scanner working quite right yet but that's another story...

Hi,

I wrote a very simplistic scanner for my dreambox recordings, which you can get here :  https://github.com/witjoh/enigma2_dreambox_scanner

Seems the scanning does work a bit, the movies are detected, but the metadata gathering does not use the name/year i thought I was passing using the mediaList array.  But that's something I need to work out how this really works.

Whenever you do a force refresh, the /tmp/scanners.dbg will be overwritten.  The output will be truncated whenever you will have an error in the code.

In my "Absolute Series Scanner" i implemented an output to a custom log (which i saw in another scanner thread), the only issue is that the path differs depending the OS, but does output logs like:

================================================================================
Scan: (root: 'G:\Anime', path='Zettai Karen Children', subdirs: ['G:\\Anime\\Zettai Karen Children\\metadata'], language: 'en')
From folder, show: 'Zettai Karen Children', year: 'None'
show: 'The Unlimited Hyoubu Kyousuke ', year: 'None', season: '01', ep: 1 found using standalone_episode_re_findall on cleaned string 'The Unlimited Hyoubu Kyousuke S01E01 Paranormal Jailbreak Schooler of Deadlock' gotten from filename 'The.Unlimited.Hyoubu.Kyousuke.S01E01.Paranormal.Jailbreak.Schooler.of.Deadlock.mkv'
show: 'The Unlimited Hyoubu Kyousuke ', year: 'None', season: '01', ep: 2 found using standalone_episode_re_findall on cleaned string 'The Unlimited Hyoubu Kyousuke S01E02 The Melody of Assassination Ghost of WW2' gotten from filename 'The.Unlimited.Hyoubu.Kyousuke.S01E02.The.Melody.of.Assassination.Ghost.of.WW2.mkv'
show: 'The Unlimited Hyoubu Kyousuke ', year: 'None', season: '01', ep: 3 found using standalone_episode_re_findall on cleaned string 'The Unlimited Hyoubu Kyousuke S01E03 Cleanliness and Pollution' gotten from filename 'The.Unlimited.Hyoubu.Kyousuke.S01E03.Cleanliness.and.Pollution.mkv'
show: 'The Unlimited Hyoubu Kyousuke ', year: 'None', season: '01', ep: 4 found using standalone_episode_re_findall on cleaned string 'The Unlimited Hyoubu Kyousuke S01E04 Absolute Domain Children Territory' gotten from filename 'The.Unlimited.Hyoubu.Kyousuke.S01E04.Absolute.Domain.Children.Territory.mkv'
show: 'The Unlimited Hyoubu Kyousuke ', year: 'None', season: '01', ep: 5 found using standalone_episode_re_findall on cleaned string 'The Unlimited Hyoubu Kyousuke S01E05 Strangers Portrait of the family' gotten from filename 'The.Unlimited.Hyoubu.Kyousuke.S01E05.Strangers.Portrait.of.the.family.mkv'
show: 'The Unlimited Hyoubu Kyousuke ', year: 'None', season: '01', ep: 6 found using standalone_episode_re_findall on cleaned string 'The Unlimited Hyoubu Kyousuke S01E06 As True as a Lie' gotten from filename 'The.Unlimited.Hyoubu.Kyousuke.S01E06.As.True.as.a.Lie.mkv'
show: 'The Unlimited Hyoubu Kyousuke ', year: 'None', season: '01', ep: 7 found using standalone_episode_re_findall on cleaned string 'The Unlimited Hyoubu Kyousuke S01E07 Generation Zero Part 1' gotten from filename 'The.Unlimited.Hyoubu.Kyousuke.S01E07.Generation.Zero.Part.1.mkv'
show: 'The Unlimited Hyoubu Kyousuke ', year: 'None', season: '01', ep: 8 found using standalone_episode_re_findall on cleaned string 'The Unlimited Hyoubu Kyousuke S01E08 Generation Zero Part 2' gotten from filename 'The.Unlimited.Hyoubu.Kyousuke.S01E08.Generation.Zero.Part.2.mkv'
show: 'The Unlimited Hyoubu Kyousuke ', year: 'None', season: '01', ep: 9 found using standalone_episode_re_findall on cleaned string 'The Unlimited Hyoubu Kyousuke S01E09 Catastrophe Pandoras box opens' gotten from filename 'The.Unlimited.Hyoubu.Kyousuke.S01E09.Catastrophe.Pandoras.box.opens.mkv'
show: 'The Unlimited Hyoubu Kyousuke ', year: 'None', season: '01', ep: 10 found using standalone_episode_re_findall on cleaned string 'The Unlimited Hyoubu Kyousuke S01E10 Distant Paradise Original Sin' gotten from filename 'The.Unlimited.Hyoubu.Kyousuke.S01E10.Distant.Paradise.Original.Sin.mkv'
show: 'The Unlimited Hyoubu Kyousuke ', year: 'None', season: '01', ep: 11 found using standalone_episode_re_findall on cleaned string 'The Unlimited Hyoubu Kyousuke S01E11 The Two Within the Storm Outlaws' gotten from filename 'The.Unlimited.Hyoubu.Kyousuke.S01E11.The.Two.Within.the.Storm.Outlaws.mkv'
show: 'The Unlimited Hyoubu Kyousuke ', year: 'None', season: '01', ep: 12 found using standalone_episode_re_findall on cleaned string 'The Unlimited Hyoubu Kyousuke S01E12 To The Future Last Revolution' gotten from filename 'The.Unlimited.Hyoubu.Kyousuke.S01E12.To.The.Future.Last.Revolution.mkv'
 

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.