# Scanner for educational material (problem with nested folders)

**URL:** <https://forums.plex.tv/t/scanner-for-educational-material-problem-with-nested-folders/86875>\
**Category:** Dev/API Corner\
**Tags:** scanner-agent-dev\
**Created:** [December 19, 2014, 3:55pm UTC](https://forums.plex.tv/t/scanner-for-educational-material-problem-with-nested-folders/86875 "2014-12-19T15:55:18Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![B0rre](https://avatars.discourse-cdn.com/v4/letter/b/c77e96/32.png) [@B0rre](https://forums.plex.tv/u/B0rre)\
**Post date:** [December 19, 2014, 3:55pm UTC](https://forums.plex.tv/t/scanner-for-educational-material-problem-with-nested-folders/86875/1 "2014-12-19T15:55:18Z")

</div>

I'm working on a custom scanner for educational videos and lectures. I've got a folder of these, organized by nested folders, roughly like:

```
Physics/
  How Things Work/
    Lecture 01.mov
    Lecture 02.mov
    Lecture 03.mov
    Lecture 04.mov
  MIT Video Lectures/
    1 - Introduction.avi
    2 - Newton's Laws.avi
    3 - Quantum Electrodynamics.avi
Music/
  How to Listen to and Understand Great Music/
    Lecture 01.mov
    Lecture 02.mov
  Another music course/
    Lecture 01.mov
    Lecture 02.mov
```

My idea was to create a TV Show section where

- the show names would be constructed from the full paths (i.e. "Physics/How Things Work" and "Music/Another music course")
- all video files in the same folder (sorted alphabetically) would be arranged as consecutive episodes in "season one" (i.e. "3 - Quantum Electrodynamics.avi" in "Physics/MIT Video Lectures" is episode 03 with episode name "3 - Quantum Electrodynamics")

I got this far with my custom scanner:

```
import re, os, os.path, time
import Media, VideoFiles, Stack

def Scan(path, files, mediaList, subdirs, language=None, root=None):  
VideoFiles.Scan(path, files, mediaList, subdirs, root)  
for nr, i in enumerate(files):  
name, year = VideoFiles.CleanName(os.path.basename(i))  
show = path if path != ‘’ else ‘Root’  
tv\_show = Media.Episode(show, 1, nr+1, name, year)  
tv\_show.parts.append(i)  
mediaList.append(tv\_show)
```

This works fine at first. All the correct tv\_show objects are created and fed to mediaList.

But the end result is not what I wanted. Somehow the scanner still only accepts one tv show per root folder.

All physics videos and all music videos are gathered into one TV show of each kind, and the different "episode 01"s and "episode 02"s from different folders are stacked together.

&nbsp;

Instead of two physics shows, I could end up with, say, just one show called "Physics/How Things Work". It will contain four episodes, and the first three of these would each contain two stacked files (one from "How Things Work" and one from "MIT Video Lectures").

&nbsp;

It seems some further logic is applied to the gathered data before or after the scanning itself. I've had a look at the Personal Media agent, but I can't see it happening there.

Any ideas or hints for allowing multiple shows per root folder?

---

<div class="post-metadata">

**Author:** ![B0rre](https://avatars.discourse-cdn.com/v4/letter/b/c77e96/32.png) [@B0rre](https://forums.plex.tv/u/B0rre)\
**Post date:** [December 21, 2014, 3:28pm UTC](https://forums.plex.tv/t/scanner-for-educational-material-problem-with-nested-folders/86875/2 "2014-12-21T15:28:03Z")

</div>

0 replies and 0 views, really?

I've taken to keeping a flat folder hierarchy with one show per top folder. That gets rid of most of the trouble.

One annoying problem remains: When one episode is completely viewed, the next one isn't automatically added to "on deck". I had hoped this feature came with media type "TV show" status.

Hints?

(Btw, googling I can see traces of a developer's documentation that now a days redirects to a non-maintained blog. I worry that the Plex team is no longer as interested in hobbyist development, custom agents, scanners and channels ..?)

---

<div class="post-metadata">

**Author:** ![Fevida](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/fevida/32/158_2.png) [@Fevida](https://forums.plex.tv/u/Fevida)\
**Post date:** [December 26, 2014, 6:19pm UTC](https://forums.plex.tv/t/scanner-for-educational-material-problem-with-nested-folders/86875/3 "2014-12-26T18:19:49Z")

</div>

This would be very useful for a lot of applications. I have all sorts of videos sorted by folders. A customizable scanner in which you are able to tell the scanner in which parental folder or part of the filename a certain piece of metadata is found would give a very flexible solution to handle these kind of old organized videos!&nbsp;

---

<div class="post-metadata">

**Author:** ![cayars](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/cayars/32/6296_2.png) [@cayars](https://forums.plex.tv/u/cayars)\
**Post date:** [December 27, 2014, 6:09pm UTC](https://forums.plex.tv/t/scanner-for-educational-material-problem-with-nested-folders/86875/4 "2014-12-27T18:09:29Z")

</div>

Guys check out the link in my signature. &nbsp;In one of the posts I show exactly how to do this.

I use this technique for learning materials and for sports shows like the NFL.

---

<div class="post-metadata">

**Author:** ![Fevida](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/fevida/32/158_2.png) [@Fevida](https://forums.plex.tv/u/Fevida)\
**Post date:** [December 27, 2014, 6:24pm UTC](https://forums.plex.tv/t/scanner-for-educational-material-problem-with-nested-folders/86875/5 "2014-12-27T18:24:47Z")

</div>

> Guys check out the link in my signature. &nbsp;In one of the posts I show exactly how to do this.
> 
> I use this technique for learning materials and for sports shows like the NFL.

Thnx for the post! It's a nice workaround, probably the best there is at the moment. If we were able to give "seasons" a name in stead of a number it would be perfect. I already took a look at te source of the extended personal media scanner and there is a mention of "season name", but after some more digging the conclusion is that Plex won't allow to change it in anything other than numbers or years.

---

<div class="post-metadata">

**Author:** ![cayars](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/cayars/32/6296_2.png) [@cayars](https://forums.plex.tv/u/cayars)\
**Post date:** [December 27, 2014, 7:17pm UTC](https://forums.plex.tv/t/scanner-for-educational-material-problem-with-nested-folders/86875/6 "2014-12-27T19:17:57Z")

</div>

Fevida, save yourself the trouble. &nbsp;I also went down the same path you are about to take! &nbsp; **SEASONS MUST BE A NUMBER**

With some of my sports libraries I wanted to do the following:

\NFL\

&nbsp; 2012\

&nbsp; &nbsp; Pre-Season 1 (all week up to)

&nbsp; &nbsp; Superbowl

&nbsp; 2013\

&nbsp; &nbsp; Pre-Season 1 (all week up to)

&nbsp; &nbsp; Superbowl

&nbsp;2014\

&nbsp; &nbsp; Pre-Season 1 (all week up to)  
&nbsp;&nbsp;&nbsp; Superbowl

Instead I had to do:

&nbsp; Pre-Season 1

&nbsp; &nbsp; 2012

&nbsp; &nbsp; 2013

&nbsp; &nbsp; 2014

&nbsp; Week 1

&nbsp; &nbsp; 2012  
&nbsp;&nbsp;&nbsp; 2013

&nbsp; &nbsp; 2014

Week 15

&nbsp; &nbsp; 2012  
&nbsp;&nbsp;&nbsp; 2013

&nbsp; &nbsp; 2014

Super Bowl

&nbsp; &nbsp; 2012  
&nbsp;&nbsp;&nbsp; 2013  
&nbsp;&nbsp;&nbsp; 2014

Reason being is the the season HAS TO BE a number and not a name in Plex itself. &nbsp;The scanner/agent could easily be changed.

So if you can make sure your "seasons" are always number then you can make the "Show Name" pretty much anything else.

So for me and NFL games I just built the libraries so the "show name" was the week and the "season" was the year. &nbsp;It's backwards from a chronological standpoint but it works and you get used to it pretty quickly.

Any way you cut it, it works and works well with any media types the built in scanners don't work with. &nbsp;Home Movies, Sporting events, learning, d/led Youtube videos, porn, etc

---

<div class="post-metadata">

**Author:** ![ZeroQI](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/zeroqi/32/6522_2.png) [@ZeroQI](https://forums.plex.tv/u/ZeroQI)\
**Post date:** [May 25, 2015, 1:20am UTC](https://forums.plex.tv/t/scanner-for-educational-material-problem-with-nested-folders/86875/7 "2015-05-25T01:20:14Z")

</div>

one tv show per root folder is a plex restriction that can be lifted if everything is added when scan function is launched at root (got the idea from itunes scanner since multiple stuff was added at once)

[https://github.com/ZeroQI/Absolute-Series-Scanner/blob/master/Series/Absolute%20Series%20Scanner.py](https://github.com/ZeroQI/Absolute-Series-Scanner/blob/master/Series/Absolute%20Series%20Scanner.py)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/plex/original/3X/2/a/2acb9765406f63293d357b4ec509ec39aa28f2ad.png) [@system](https://forums.plex.tv/u/system)\
**Post date:** [December 21, 2019, 3:55am UTC](https://forums.plex.tv/t/scanner-for-educational-material-problem-with-nested-folders/86875/8 "2019-12-21T03:55:05Z")

</div>

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