# Plex/Nine Database

**URL:** https://forums.plex.tv/t/plex-nine-database/3453
**Category:** Dev/API Corner
**Tags:** other-dev
**Created:** [January 20, 2010, 4:15pm UTC](https://forums.plex.tv/t/plex-nine-database/3453 "2010-01-20T16:15:40Z")
**Posts on this page:** 20
**Page:** 10

<div class="post-metadata">

### Author: ![Advocate](https://avatars.discourse-cdn.com/v4/letter/a/9d8465/32.png) [@Advocate](https://forums.plex.tv/u/Advocate)
#### Post date: [April 22, 2010, 9:11pm UTC](https://forums.plex.tv/t/plex-nine-database/3453/181 "2010-04-22T21:11:41Z")

</div>

Are we there yet? Are we? Are we?

---

<div class="post-metadata">

### Author: ![elan](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/elan/32/5_2.png) [@elan](https://forums.plex.tv/u/elan)
#### Post date: [April 22, 2010, 9:15pm UTC](https://forums.plex.tv/t/plex-nine-database/3453/182 "2010-04-22T21:15:20Z")

</div>

Every time I get a notification of a new post here and come check, hoping for some intelligent discorse on life, the universe, and databases, and read another “me too” post, the Alexandria library loses about 30 seconds of development time. Just saying.

---

<div class="post-metadata">

### Author: ![GSX](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/gsx/32/951_2.png) [@GSX](https://forums.plex.tv/u/GSX)
#### Post date: [April 22, 2010, 9:43pm UTC](https://forums.plex.tv/t/plex-nine-database/3453/183 "2010-04-22T21:43:03Z")

</div>

> [@](#):
>
> Every time I get a notification of a new post here and come check, hoping for some intelligent discorse on life, the universe, and databases, and read another "me too" post, the Alexandria library loses about 30 seconds of development time. Just saying.

  
  
I have a real question about Plex 9 then.  
  
I have only starting using Plex recently(version 8.5) and so I have no experience with major new version releases or updates. What will happen to our current libraries and preferences when we upgrade to Plex 9? Will we have to re-scrape everything? Or will Plex 9 recognize our current libraries, thumbs, backdrops, etc.?

---

<div class="post-metadata">

### Author: ![elan](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/elan/32/5_2.png) [@elan](https://forums.plex.tv/u/elan)
#### Post date: [April 22, 2010, 9:48pm UTC](https://forums.plex.tv/t/plex-nine-database/3453/184 "2010-04-22T21:48:52Z")

</div>

This is a MAJOR revision (doesn’t get more major than this), you’ll have to re-create your library.  
  
  
  
(This is not to say that a migration app couldn’t be written, we just don’t have the bandwidth to create one.)

---

<div class="post-metadata">

### Author: ![GSX](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/gsx/32/951_2.png) [@GSX](https://forums.plex.tv/u/GSX)
#### Post date: [April 22, 2010, 9:57pm UTC](https://forums.plex.tv/t/plex-nine-database/3453/185 "2010-04-22T21:57:02Z")

</div>

> [@](#):
>
> This is a MAJOR revision (doesn't get more major than this), you'll have to re-create your library.  
>   
> (This is not to say that a migration app couldn't be written, we just don't have the bandwidth to create one.)

  
  
Thanks for the fast reply.   
  
I had a feeling that might be the case, but that's cool. My library is only about 100 DVDs so it would not take long to fix it.  
  
Too bad for those people with huge libraries though. :P

---

<div class="post-metadata">

### Author: ![Fressa0815](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/fressa0815/32/727_2.png) [@Fressa0815](https://forums.plex.tv/u/Fressa0815)
#### Post date: [April 22, 2010, 10:32pm UTC](https://forums.plex.tv/t/plex-nine-database/3453/186 "2010-04-22T22:32:13Z")

</div>

> [@](#):
>
> Thanks for the fast reply.   
>   
> I had a feeling that might be the case, but that's cool. My library is only about 100 DVDs so it would not take long to fix it.  
>   
> Too bad for those people with huge libraries though. :P

  
  
It's not that bad. I think one cold and rainy sunday should be enoug to scrape my 500 movies (incl. DVDs) and 1300 Tv-Episodes.   
I'm very curious about the Agents in Alexandria, because the Data from Ofdb.de is mostly crap and the possibility to combine the Data from e.g. imdb (Actors, genre, director) and ofdb (plot) makes me laugh, sing and dance! Will it realy be this easy?

---

<div class="post-metadata">

### Author: ![elan](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/elan/32/5_2.png) [@elan](https://forums.plex.tv/u/elan)
#### Post date: [April 22, 2010, 10:36pm UTC](https://forums.plex.tv/t/plex-nine-database/3453/187 "2010-04-22T22:36:05Z")

</div>

> [@](#):
>
> I'm very curious about the Agents in Alexandria, because the Data from Ofdb.de is mostly crap and the possibility to combine the Data from e.g. imdb (Actors, genre, director) and ofdb (plot) makes me laugh, sing and dance! Will it realy be this easy?

  
  
All the underpinnings are there, I don't expect it to be fully exposed in the first alpha, but that's EXACTLY the scenario we're targeting. In fact, now that I think about it, I think that would even work fine right now :) We just don't have an OFDB agent yet, but if one existed, and it just returned summary, you could prioritize it above IMDB.  
  
Sing! Dance! Laugh!

---

<div class="post-metadata">

### Author: ![noiz](https://avatars.discourse-cdn.com/v4/letter/n/dec6dc/32.png) [@noiz](https://forums.plex.tv/u/noiz)
#### Post date: [May 1, 2010, 12:44am UTC](https://forums.plex.tv/t/plex-nine-database/3453/188 "2010-05-01T00:44:59Z")

</div>

I don’t really know if this is the right place to post this, but i try here. Im sorry if im wrong.  
  
  
  
Can Plex Nine detect when i add a file to one of my source and update the libary automaticly?  
  
  
  
So when my download is finsished it automaticly scrape it.

---

<div class="post-metadata">

### Author: ![radar](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/radar/32/332_2.png) [@radar](https://forums.plex.tv/u/radar)
#### Post date: [May 2, 2010, 6:14pm UTC](https://forums.plex.tv/t/plex-nine-database/3453/189 "2010-05-02T18:14:45Z")

</div>

The folder action, combined with a script that launches the database update, should answer your request.  
  
You can also launch the script from the app you use to download your stuff.  
  
Here is my update script, inspired from a post on this forum:

```auto

#!/bin/zsh<br />
<br />
seriesPath=/Volumes/Capsule/Series/<br />
ip=10.0.1.31<br />
<br />
#see if plex is running<br />
#ps lists grep along with any actual instances of Plex.app<br />
numPlexes=$(( $(/bin/ps -A | /usr/bin/grep /Applications/Plex.app | wc -l) ))<br />
<br />
#only call update if Plex is running<br />
if [[$numPlexes -gt 0]]; then <br />
echo updating...<br />
/usr/bin/logger updating Plex library<br />
/usr/bin/curl -o /dev/null --stderr /dev/null --silent --get "http://$ip:3000/xbmcCmds/xbmcHttp?command=ExecBuiltIn&parameter=XBMC.updatelibrary(video)"<br />
fi<br />
<br />
if [[$numPlexes = 0]]; then<br />
echo No Plex running on $ip<br />
fi

```

---

<div class="post-metadata">

### Author: ![atrus](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/atrus/32/31_2.png) [@atrus](https://forums.plex.tv/u/atrus)
#### Post date: [May 2, 2010, 10:00pm UTC](https://forums.plex.tv/t/plex-nine-database/3453/190 "2010-05-02T22:00:48Z")

</div>

> [@](#):
>
> I don't really know if this is the right place to post this, but i try here. Im sorry if im wrong.  
>   
> Can Plex Nine detect when i add a file to one of my source and update the libary automaticly?  
>   
> So when my download is finsished it automaticly scrape it.

  
Dont worry, PlexNine will save the day ;)

---

<div class="post-metadata">

### Author: ![Advocate](https://avatars.discourse-cdn.com/v4/letter/a/9d8465/32.png) [@Advocate](https://forums.plex.tv/u/Advocate)
#### Post date: [May 2, 2010, 11:12pm UTC](https://forums.plex.tv/t/plex-nine-database/3453/191 "2010-05-02T23:12:51Z")

</div>

Will 0.9 give us the option to scrape different items from different places? IE Get the movie info from one site and the thumb from another?  
  
  
  
Also how will 0.9 handle media flags? Will it perform analysis of my media files for things like resolution/soundtrack etc?  
  
  
  
Will we be able to add our own media flags for studios etc or will they all be controlled centrally?

---

<div class="post-metadata">

### Author: ![elan](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/elan/32/5_2.png) [@elan](https://forums.plex.tv/u/elan)
#### Post date: [May 2, 2010, 11:17pm UTC](https://forums.plex.tv/t/plex-nine-database/3453/192 "2010-05-02T23:17:26Z")

</div>

> [@](#):
>
> Will 0.9 give us the option to scrape different items from different places? IE Get the movie info from one site and the thumb from another?

  
  
Yes, available in first alpha.  
  

> [@](#):
>
> Also how will 0.9 handle media flags? Will it perform analysis of my media files for things like resolution/soundtrack etc?

  
  
Yes, available in first alpha.  
  

> [@](#):
>
> Will we be able to add our own media flags for studios etc or will they all be controlled centrally?

  
  
Controlled centrally, but if you care enough you can mark the flags bundle as "dev" and throw your own in there.

---

<div class="post-metadata">

### Author: ![Advocate](https://avatars.discourse-cdn.com/v4/letter/a/9d8465/32.png) [@Advocate](https://forums.plex.tv/u/Advocate)
#### Post date: [May 2, 2010, 11:45pm UTC](https://forums.plex.tv/t/plex-nine-database/3453/193 "2010-05-02T23:45:58Z")

</div>

Fantastic! I’m hoping then that Plex will simply display all the available info it’s managed to glean for a movie/tv show etc and let me choose.  
  
  
  
I’m thinking controlled centrally is the better option to be honest. Will you have things in place to allow users to submit new media flags for approval?  
  
  
  
  
  
  
  
And being totally OT here but any news on when the skinning engine will be “Plexified” to the same extent the rest of it has? (I want a simple skinning engine dammit! 😉 )

---

<div class="post-metadata">

### Author: ![chipadeedoodah](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chipadeedoodah/32/286805_2.png) [@chipadeedoodah](https://forums.plex.tv/u/chipadeedoodah)
#### Post date: [May 3, 2010, 12:19am UTC](https://forums.plex.tv/t/plex-nine-database/3453/194 "2010-05-03T00:19:07Z")

</div>

> [@](#):
>
> The folder action, combined with a script that launches the database update, should answer your request.  
> You can also launch the script from the app you use to download your stuff.  
> Here is my update script, inspired from a post on this forum:

  
  
This numplexes thing is unnecessary & ugly, and seriesPath never even gets called. Cleaner, more reliable script:  
  

```auto

<br />
#!/bin/bash<br />
<br />
#see if plex is running<br />
/bin/ps -A | /usr/bin/grep Applications/Plex.app | /usr/bin/grep -v grep > /dev/null<br />
<br />
#Act accordingly<br />
if [[$! -eq 0]]; then<br />
     #Update Plex<br />
     /usr/bin/logger updating Plex library<br />
     /usr/bin/curl -o /dev/null --stderr /dev/null --silent --get "http://127.0.0.1:3000/xbmcCmds/xbmcHttp?command=ExecBuiltIn&parameter=XBMC.updatelibrary(video)"<br />
else<br />
     #Log failure<br />
     /usr/bin/logger No Plex running on localhost<br />
fi<br />

```

---

<div class="post-metadata">

### Author: ![radar](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/radar/32/332_2.png) [@radar](https://forums.plex.tv/u/radar)
#### Post date: [May 3, 2010, 7:28am UTC](https://forums.plex.tv/t/plex-nine-database/3453/195 "2010-05-03T07:28:34Z")

</div>

The seriesPath was used to specify one specific folder to update, but it seems it does not work. So, you’re right, it’s never called. The numplexes checkes if plex is running, so it is usefull.

> [@](#):
>
> This numplexes thing is unnecessary & ugly, and seriesPath never even gets called. Cleaner, more reliable script:

---

<div class="post-metadata">

### Author: ![El\_Massman](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/el_massman/32/75_2.png) [@El\_Massman](https://forums.plex.tv/u/El_Massman)
#### Post date: [May 3, 2010, 11:37am UTC](https://forums.plex.tv/t/plex-nine-database/3453/196 "2010-05-03T11:37:32Z")

</div>

ok, got a question. i haven’t seen an answer for it anywhere else yet…  
  
  
  
one of my main hard drives recently broke, possibly due to a combination of overheating and being constantly on. (wholey because of your fine media playing app i might add!) because of this i’ve invested in a sata hotswap bay so i only have whichever drive i need connected at any one time. will there be features such as hiding any media for which the hard drive/pen drive/disc is not currently mounted? i’d love to only be able to see what’s currently connected while still having my offline files stored in the library ready to pop back up the second i add another drive. perhaps a switch to toggle hiding offline files? it’d still be great to be able to see everything i have, maybe with something like a ‘please insert/your file is located on drive ‘x’.’ secondly and kinda related, because it’s now impossible for me to have all of my media plugged in at any one time i am unable to use the ‘clean library’ feature. is cleaning the library still needed under 9 and if so, would it be possible for me do something like clean the library for only the currently connected sources? this way i could tidy up anything i’ve deleted without removing my whole offline library.  
  
  
  
thanks,  
  
  
  
marc

---

<div class="post-metadata">

### Author: ![chipadeedoodah](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chipadeedoodah/32/286805_2.png) [@chipadeedoodah](https://forums.plex.tv/u/chipadeedoodah)
#### Post date: [May 3, 2010, 3:08pm UTC](https://forums.plex.tv/t/plex-nine-database/3453/197 "2010-05-03T15:08:20Z")

</div>

> [@](#):
>
> The numplexes checkes if plex is running, so it is usefull.

  
  
There's a few different versions of this script floating around, and I didn't read yours closely enough. This particular variant fires if numplexes \> 0, which means it will always fire, even if Plex isn't running, because as written numplexes will always be greater than zero. I'll demonstrate.  
  
Here's an example from a computer that is running Plex:  

```auto

<br />
Burn-e:~ chip$ /bin/ps -A | /usr/bin/grep /Applications/Plex.app<br />
  555 ?? 227:48.42 /Applications/Plex.app/Contents/MacOS/Plex -psn_0_188462<br />
29828 ttys002 0:00.00 /usr/bin/grep /Applications/Plex.app<br />
Burn-e:~ chip$ /bin/ps -A | /usr/bin/grep /Applications/Plex.app | wc -l<br />
       2<br />

```

  
  
Here's an example from a computer that is not running Plex:  

```auto

<br />
eve:~ chip$ /bin/ps -A | /usr/bin/grep /Applications/Plex.app<br />
 3507 ttys000 0:00.00 /usr/bin/grep /Applications/Plex.app<br />
eve:~ chip$ /bin/ps -A | /usr/bin/grep /Applications/Plex.app | wc -l<br />
       1<br />

```

  
  
So for the script you have posted to work as written, you need to run the update only if numplexes \> 1, not \> 0 as your ifcase states. However, the whole numplexes thing originated as a workaround for the fact that the ps | grep command as written here will always return itself as well as any Plex instances. For a much cleaner way to deal with this, pipe to grep a second time with -v, the inverse-match argument, and tell it not to match against grep. This effectively filters out grep from the result set, and now we have a shell boolean. Either we will find Plex.app running and return true, or we'll find Plex.app isn't running, and return false. No line counts are needed to create a condition for the ifcase, so we just direct the output to null.  
  
Here's an example from a computer that is running Plex:  

```auto

<br />
Burn-e:~ chip$ /bin/ps -A | /usr/bin/grep Applications/Plex.app | /usr/bin/grep -v grep<br />
  555 ?? 229:33.62 /Applications/Plex.app/Contents/MacOS/Plex -psn_0_188462<br />
Burn-e:~ chip$<br />

```

  
  
Here's an example from a computer that is not running Plex:  

```auto

<br />
eve:~ chip$ /bin/ps -A | /usr/bin/grep Applications/Plex.app | /usr/bin/grep -v grep<br />
eve:~ chip$<br />

```

  
  
So then, instead of counting the number of results of our grep test, we can just test against true/false, and write the ifcase like so:  
  

```auto

<br />
if [[$! -eq 0]]; then<br />

```

  
  
If we really wanted to play script hockey we could combine the grep statement into the ifcase test, but that lowers readability considerably.  
  
(A final note: All this fancy logic to determine whether Plex is running or not isn't particularly necessary, it's just nice. Running an http request against a closed port just makes curl fail, it doesn't have any longterm ill effect.)  
  
So to sum up: Every shell command is already a boolean, and will return either 0 (success) or 1 (fail). Pipe grep back to grep -v grep to filter out grep from its own search results, and then use the success/failure of your command as the boolean for an ifcase rather than kludging linecounts to turn a grep result set into a boolean for testing.  
  
Or, like I said before: This numplexes thing is unnecessary & ugly.

---

<div class="post-metadata">

### Author: ![jam](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/jam/32/186050_2.png) [@jam](https://forums.plex.tv/u/jam)
#### Post date: [May 3, 2010, 3:41pm UTC](https://forums.plex.tv/t/plex-nine-database/3453/198 "2010-05-03T15:41:02Z")

</div>

Can we try to stay on topic, please? This thread’s for discussion of the new library database in 0.9, not scripts that update the old library in 0.8 🙂

---

<div class="post-metadata">

### Author: ![noiz](https://avatars.discourse-cdn.com/v4/letter/n/dec6dc/32.png) [@noiz](https://forums.plex.tv/u/noiz)
#### Post date: [May 3, 2010, 10:01pm UTC](https://forums.plex.tv/t/plex-nine-database/3453/199 "2010-05-03T22:01:39Z")

</div>

> [@](#):
>
> Dont worry, PlexNine will save the day ;)

  
  
Well that's good to hear, this PlexNine really sound like a MAJOR MAJOR update. can we compare it to Leopard to snow leopard? :)

---

<div class="post-metadata">

### Author: ![elan](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/elan/32/5_2.png) [@elan](https://forums.plex.tv/u/elan)
#### Post date: [May 3, 2010, 10:03pm UTC](https://forums.plex.tv/t/plex-nine-database/3453/200 "2010-05-03T22:03:48Z")

</div>

> [@](#):
>
> Well that's good to hear, this PlexNine really sound like a MAJOR MAJOR update. can we compare it to Leopard to snow leopard? :)

  
  
I'd like to compare it more to the move from Windows to the Mac. Things are easier, life is better.

[Previous page](https://forums.plex.tv/t/plex-nine-database/3453.md?page=9)

[Next page](https://forums.plex.tv/t/plex-nine-database/3453.md?page=11)
