Parental Control Channel for PMS

Nice detective work. I don't think it'll take much to tweak the code for this addition. I'll try to get it updated for testing within the next couple days.

Thank you! I needed to put on my plex glasses :P

Is there a (graceful) way to combine the "UPDATE metadata_items" commands with the ones already being used? My thought is that adding the extra command in sequence rather than parallel means that we're essentially traversing the database twice when locking or unlocking. For large sections that may make a noticeable difference. Or do I not have the concept quite right?

You got the concept right and I see later you implemented the concept brilliantly : )

Can I humbly suggest, that instead of setting the metadata type to 20, then instead add 666 to it.

That way, when unlocking, you substract 666 and get the origen type, thus making it universal for both movies, TV-Shows, and all other currently defined types.

/T

:D

After doing a little more sqlite reading, I think I have a grasp on the way to combine the statements for efficiency.

LOCK_COMMAND_1 = "UPDATE metadata_items SET added_at=?, metadata_type=20 WHERE library_section_id=?;"
# section['section_created_at'], section['section_id']

and 

UNLOCK_COMMAND_1 = "UPDATE metadata_items SET added_at=?, metadata_type=? WHERE library_section_id=?;"
# section['section_created_at'], section['section_type'], section['section_id']

Perfect!

Looks like it's throwing an error because it's trying to execute the lock command with no Sections selected. Most likely a by-product of the issues with the setup wizard.

I have 2 concerns with switching from the setup wizard to using prefs.

  1. There's no proper way to protect the prefs. All users have access to change passwords, change selected sections, etc.
  2. It's not possible to build a list of prefs dynamically. So allowing users to select which section(s) to lock is not possible via the prefs menu.

I suppose we could use a combination of prefs (for password) and setup wizard (for selecting sections) but that still leaves the gaping security hole associated with the ease of changing password.

@dane22: I think you'll need to manually delete the Dict file for your install to reset the First Run Wizard.

I know that the issue with Plex/Web's handling of multiple InputDirectoryObject's has been brought up before. I'll try to find out if a fix for that is on the horizon. I suspect that if we can't support Plex/Web, that there will be a lot of users getting very frustrated.

Ok, to summarize we have two problems:

  1. Setup of the channel
  2. Using PMS internal sqlite3 to make the plugin more cross-platform

Regarding #1 and mind you I’m just thinking out loud here! Is it possible to @route to a HTML.

I was going through the YouTube bundle here  (I don’t have a choice I just browse through code coz I’m no good at channel building) and noticed the below lines (133-135)

 page_content = HTTP.Request(YOUTUBE_LIVE, cacheTime=0).content
 page = HTML.ElementFromString(page_content)
 live_now = page.xpath("//div[contains(@id,'video-page-content')]")[0]

I am guessing page_content is pulling content from a HTML file. I really don’t know what I’m talking about but is it possible to import a static HTML that exists within the bundle? A HTML that is formatted the “plex” way to display all object containers?

If yes, the setup can be done via a HTML that has section data populated via XML(like Mike’s code is currently displaying) and password and confirm password in one page. What I am getting at is Javascript could be used to validate if selections are selected and if the password matches as well.  The goal is to save the data in Dict so that too could be done via javascript. I saw the search route uses some version of jQuery. So it is possible, in theory at least?

Completely agree that plexWeb should be the base for setup.

Went through your code from an amateur perspective and could not find the co-relation between SectionSelector and SelectThiSection when does the SelectThiSection get called(event). Maybe that’s why the section is not getting selected.

Also could this(screenshot below) object(checkbox) that we see in PlexWeb be used to select the selections.
 

![post-220329-0-58754600-1405666563.jpg|222x500](upload://qnZWU2ZHOBXUm6WyoMFiNx43TU4.jpg)

Regarding#2     >.>         <.<       -.-       0.0

Ok, to summarize we have two problems:

  1. Setup of the channel
  2. Using PMS internal sqlite3 to make the plugin more cross-platform

Regarding #1 and mind you I’m just thinking out loud here! Is it possible to @route to a HTML.

I was going through the YouTube bundle here  (I don’t have a choice I just browse through code coz I’m no good at channel building) and noticed the below lines (133-135)

 page_content = HTTP.Request(YOUTUBE_LIVE, cacheTime=0).content
 page = HTML.ElementFromString(page_content)
 live_now = page.xpath("//div[contains(@id,'video-page-content')]")[0]

I am guessing page_content is pulling content from a HTML file. I really don’t know what I’m talking about but is it possible to import a static HTML that exists within the bundle? A HTML that is formatted the “plex” way to display all object containers?

If yes, the setup can be done via a HTML that has section data populated via XML(like Mike’s code is currently displaying) and password and confirm password in one page. What I am getting at is Javascript could be used to validate if selections are selected and if the password matches as well.  The goal is to save the data in Dict so that too could be done via javascript. I saw the search route uses some version of jQuery. So it is possible, in theory at least?

Completely agree that plexWeb should be the base for setup.

Channel's are not able/allowed to display HTML content. The channel code (with the Framework as a middleman) just generates XML which then the client apps interpret and display according to their own design esthetics. We actually have very little control over how things look in any given app.  It's possible to load a stored file from within the channel bundle, it's used regularly for images. I've also used it for JSON, and it could work for XML, text, or basically any file type that the channel code knows how to handle. I had considered offering the option to manually edit a preferences-like file stored in the channel bundle but that really isn't the best option IMO. FWIW, those 3 lines of code from the YouTube channel basically say:

  1. Make an HTTP request for the content of the page represented by the URL stored as "YOUTUBE_LIVE" (which will be referenced at the top of the plugin code). Assign that content to the variable "page_content".
  2. Parse the string content of variable "page_content" as a HTML and save it to a new variable "page"
  3. Parse the HTML of "page" using xpath for the first div element with the id "video-page-content" and assign that element to a variable "live_now".

 

Went through your code from an amateur perspective and could not find the co-relation between SectionSelector and SelectThiSection when does the SelectThiSection get called(event). Maybe that’s why the section is not getting selected.

The function SelectThinSection() is assigned to the Callback for the DirectoryObjects in the SectionSelector. See here.

Also could this(screenshot below) object(checkbox) that we see in PlexWeb be used to select the selections.
 

attachicon.gif CheckBox.jpg

Regarding#2     >.>         <.<       -.-       0.0

As per my notes above, we don't have that type of control. The only thing we could do is use custom icons (which would need to be included in the bundle) for selected vs unselected.

Thank you : )

It's possible to load a stored file from within the channel bundle, it's used regularly for images. I've also used it for JSON, and it could work for XML, text, or basically any file type that the channel code knows how to handle.

-- Thanks will experiment with sqlite3

I had considered offering the option to manually edit a preferences-like file stored in the channel bundle but that really isn't the best option IMO.

-- I agree, at the moment though, looks like this would be the best option

The function SelectThinSection() is assigned to the Callback for the DirectoryObjects in the SectionSelector. See here.

-- Thank you, was very clumsy of me to miss it

I was having a look at dane22’s Plex2CSV and realized there must be a few dev’s who would like more customizable apps. At least to setup. Then I thought of the Plex Crew, those guys probably feel once they open that can of worms it could be used to do potentially harmful stuff. Don’t see how. Maybe they just want a controlled GUI using the existing div containers and XML. Anyway, in short, I feel they don’t have a choice. Maybe fixing the InputDirectoryObject for Plex/Web itself would be a daunting task, seeing that it has a fixed container in Plex/Web and the fact that we are misusing the search field for stuff like passwords, innovative but their answer will prolly be to use the preferences.

I really liked your option of having a preferences file, it won’t be the most “user friendly” but at least it will get the job done. We could use the gmail login API to validate for lock or unlock. In gmail the user would have to approve the usage of gmail credentials for the Lock app (crazy farfetched solution I know, restricting gmail accounts to only the one specified would be a task too).

Just sharing thoughts!

I saw the Plex Channel kickstarter a while ago when starting with the lock app and it got me thinking and led me to have the .command shortcuts separate and the plugin separate. Not cross-platform but using separate parts of sorts.

Something like, you have probably heard of, ShowRSS and Catch. Now, showRSS saves all the preferences online and does all the scheduling of TV shows and is easily customizable, whereas Catch is a simple program on OS X that just uses the input URL of ShowRSS to help download the shows fed by the ShowRSS feed.

Would this kind of architecture be used to setup apps in Plex Channels. A simple free wordpress webpage that gets the XML sections URL of Plex from the user who allows the browser to access Plex does the logic allows the selection of sections, allows the password to be saved and then returns a string of values (not necessary to have a evolved user database like ShowRSS so as to use a specific user based URL to get values in the plugin) that can be pasted into preferences and saved. Henceforth preferences would/should be greyed out.

Just sharing thoughts, it would be a lot of work for a not so productive app which is just for fun/locking adult material!

Ok, so inspired by the kickstart plugin creator set out to create a HTML file with some jQuery to fetch the data we need.

I got surprisingly further that I thought I would:

![post-220329-0-14572100-1406126733.jpg|690x397](upload://rStOlkEZoXQio9Qy7owY7lgP8kz.jpg)

![post-220329-0-51407400-1406126753.jpg|690x434](upload://A4bSQnRm0O02G9RlM3C1plUT1ZD.jpg)

So now I am at a stage where, I have as a "alert"(temporary) which shows the LOCK and UNLOCK consolidated commands and Password string(s). I would ideally like to now insert those string(s) into the __init__.py directly. Wanted to generate a plugin with the values like the  kickstart plugin creator.

Need some help:

(1) Don't have a clue as to what kind of PHP is generating the plugin as a .zip kickstart plugin creator, does anyone know/can help by pointing me to the right direction O.O

(2) Anyone(Mike) want to take over the lil experiment (seriously don't have the bandwidth/depth of knowledge at the moment)

(3) Anyone know of a free web hosting where I could maybe upload the HTML and some supported files (at the moment I could just put everything into one HTML file, i.e. no external css, js and images, just one HTML file)

(4) Will share the code when I have done the queries bit!

UPDATE:

Link to HTML

![post-220329-0-84234500-1406142898.jpg|690x429](upload://1KMm5TWFqyY0DybgMT5EzyDfyav.jpg)

![post-220329-0-67397100-1406142932.jpg|690x436](upload://aVc03ZagkNvTu2avCVkGwSBlogi.jpg)

UPDATE:

Updated the HTML/js to display the code to be copied and manually put into the __init__.py or hopefully someday ; ) have this HTML on a server and use PHP to generate the files dynamically to offer a downloadable Lock.bundle.zip file. (I wouldn't hold my breath)

![post-220329-0-70134700-1406196189.jpg|690x424](upload://bZkBu9M1WjwrccuQfSuHl0RBWAb.jpg)

Looking forward to seeing some progress via the plugin creator approach

nice work!

I'm not really familiar with the kickstarter code (or php). IIRC, GitHub offers free hosting for project pages. I've never really looked into it, but it seems like it might be a good hosting option for this.

Just for the fun of it, try this:

Rename the directory named "Customize Lock Plugin_files" to "lock"

Rename the html file to lock.html

In the html file, rename all instance of "./Customize Lock Plugin_files/" to "lock/"

Put both above into the following location:

/Library/Plex Media Server/Plug-ins/WebClient.bundle/Contents/Resources

Then browse to: http://:32400/web/lock.html

/Tommy

Just for the fun of it, try this:

Rename the directory named "Customize Lock Plugin_files" to "lock"

Rename the html file to lock.html

In the html file, rename all instance of "./Customize Lock Plugin_files/" to "lock/"

Put both above into the following location:

/Library/Plex Media Server/Plug-ins/WebClient.bundle/Contents/Resources

Then browse to: http://:32400/web/lock.html

/Tommy

That's an interesting concept. FWIW, whether it works or not, the bundle will be automatically replaced by PMS (usually within an hour), unless you set the dev mode flag in the plist or use a sym-linked copy instead.

the bundle will be automatically replaced by PMS (usually within an hour), unless you set the dev mode flag in the plist or use a sym-linked copy instead.

Didn't happen here.

Might be due to the fact, that I don't change anything existing, just dump some additional files into the directory

/T

Didn't happen here.

Might be due to the fact, that I don't change anything existing, just dump some additional files into the directory

/T

And stand corrected here.....stuff did vanish....guess it survived the night due to my NAS was sleeping  :(

/T

Looking forward to seeing some progress via the plugin creator approach

nice work!

Yeah! Thank you! It is thanks to Mike's initial logic, just trying desperately to take it further.

//TODO

1) Find a way to rip the php code :D from the plex dev site to see how the kickstart plugin is generated (had no luck so far)

2) Find a host which lets us upload php scripts and allows us to execute them, haven't tried placing a php file in the git repo and trying to call it via HTML/js yet!

3) Request Milke to amend lock code to allow it to use sub process in .py to launch the lock and unlock commands in either OS X(terminal), Windows(command prompt) or Linux(terminal), have not seen any way to access/use the sqlite file within PMS, yet! There would bound to be a permissions issue in Linux(unless you've made plex yours in linux ; )), dunno about the others.

Although I would love to get your hopes up high ; ) haven't been able to spend time on this. It is erratic, sporadic at best!

I'm not really familiar with the kickstarter code (or php). IIRC, GitHub offers free hosting for project pages. I've never really looked into it, but it seems like it might be a good hosting option for this.

Cool! Thanks though. Will pick your brain later ; ) once I figure out how to do the do ; )

Just for the fun of it, try this:

Rename the directory named "Customize Lock Plugin_files" to "lock"

Rename the html file to lock.html

In the html file, rename all instance of "./Customize Lock Plugin_files/" to "lock/"

Put both above into the following location:

/Library/Plex Media Server/Plug-ins/WebClient.bundle/Contents/Resources

Then browse to: http://:32400/web/lock.html

/Tommy

Dude, I have no clue how to do dat! Looks neat though : ) Cheers!

Dude, I have no clue how to do dat! Looks neat though : ) Cheers!

Put attached somewhere on your PMS box

Then in the webclient.bundle/resource directory, create a symbolic link named lock that points to the attached

Also note, that I made a small change to your js, so it autodetect the url

After that, browse to http://:32400/web/lock/lock.html

Edit: forgot attachment

Put attached somewhere on your PMS box

Then in the webclient.bundle/resource directory, create a symbolic link named lock that points to the attached

Also note, that I made a small change to your js, so it autodetect the url

After that, browse to http://:32400/web/lock/lock.html

Edit: forgot attachment

Very Neat :D

@All

Check out the latest progress here.

Managed to dish out a .zip file with a __init__.py that includes the lock and unlock sql commands ; )

//TODO

1) Initially try to dish out the lock.command and unlock.command in a zip file for OS X so peeps can use it with the existing latest lock.bundle (my repo) Done! check OP!

2) See if the script can read the various files required for the bundle and then dish it out in a zip after writing stuff to it!

No ETA :D

Have a great weekend : )

I just tried the lock command creator. Whilst it looks good but it does not download any commands to my PMS OS-X Server. Any hint?

I just tried the lock command creator. Whilst it looks good but it does not download any commands to my PMS OS-X Server. Any hint?

This is not a released solution, but in a very early pre-Alpha state development work....

If your are not a developer, I urge you to read the following line:

"Nothing to see here....move along"  :D

If you on the other hand are a developer, living on the edge, then do dig in, but note that this is not an ordinary project, but something that digs directly down into the database, and as such, it potential dangerous

/T

I just tried the lock command creator. Whilst it looks good but it does not download any commands to my PMS OS-X Server. Any hint?

Hmm. Try creating the commands from a client PC/mac on your local network not necessary for you to be on the PMS server machine itself whilst creating the commands.

This is not a released solution, but in a very early pre-Alpha state development work....

If your are not a developer, I urge you to read the following line:

"Nothing to see here....move along"  :D

If you on the other hand are a developer, living on the edge, then do dig in, but note that this is not an ordinary project, but something that digs directly down into the database, and as such, it potential dangerous

/T

Thanks

Given the js code a facelift ; ) would appreciate it if devs could have a look and suggest changes, most of the code is based on Mike's work/inputs.

Check it out ;) here

Thanks.

1) Plug-in Generation -- Done

2) Usage of sqlite3 -- Done (I'm guessing it only works on select OS's and on any OS X above 10.7.5)

3) Requires Testing -- //TODO

Need to know if it would be better to open the sql queries using subprocess in terminal allowing the user the option to use their own sqlite3 version/path to sqlite3!

Can I humbly suggest, that you switch away from the plug-in generation model?

Attached is a small plugin, that can grap your parameters from your js script, but currently only simply print the url to the console, so it needs to be merged into Mike's plugin  :rolleyes:

But what will then happen, is that you after selecting the section, simply send an url to the PMS, and a section will be locked!

Sample URL for locking a section:

http://PMS:32400/applications/lock/Lock?pwd=hello55&lock=true&section=3&title=mymovies

Sample URL for unlocking a section:

http://PMS:32400/applications/lock/Lock?pwd=hello55&lock=false&section=3&title=mymovies&section_type=1&lang=en&agent=com.plexapp.agents.imdb&scanner=Plex%20Movie%20Scanner&created_at=2014-07-22%2012:41:02&updated_at=2014-07-32%2021:29:50&scanned_at=2014-07-32%2021:29:50&uuid=a7af65ac-2726-4917-8cb8-41cb762aa53a

Best Regards

Tommy

Can I humbly suggest, that you switch away from the plug-in generation model?

Attached is a small plugin, that can grap your parameters from your js script, but currently only simply print the url to the console, so it needs to be merged into Mike's plugin  :rolleyes:

But what will then happen, is that you after selecting the section, simply send an url to the PMS, and a section will be locked!

Sample URL for locking a section:

http://PMS:32400/applications/lock/Lock?pwd=hello55&lock=true&section=3&title=mymovies

Sample URL for unlocking a section:

http://PMS:32400/applications/lock/Lock?pwd=hello55&lock=false&section=3&title=mymovies&section_type=1&lang=en&agent=com.plexapp.agents.imdb&scanner=Plex%20Movie%20Scanner&created_at=2014-07-22%2012:41:02&updated_at=2014-07-32%2021:29:50&scanned_at=2014-07-32%2021:29:50&uuid=a7af65ac-2726-4917-8cb8-41cb762aa53a

Best Regards

Tommy

Hmm, my intention was to provide a simple/secure/user friendly solution! I am even looking for a way I can incorporate some sort of GDM into the jQuery so as to discover the plex server on a local network when the user visits the Lock plugin generation page. Making it even more user friendly. I predicted browser security issues and hence didn't go that way.

Although I think I know what you’re saying, still unclear as to where the js will reside in your scenario and if the url passing the values like “password” will need to be cleared from the browser history to not allow a smart kid to unlock using the history of links used ; )

I kinda found my method to be neat and like outta the box, but hey, I’m just having fun :D you guys are veterans so appreciate the advice!

For now looking for:

  1. Usage of PMS inbuilt sqlite3.so to run the query’s or maybe Mike’s suggestion of using subprocess to run the commands via terminal and then giving the user some sort of option during plugin generation, based on their OS X version of choosing where the sqlite3 resides…
  2. Looking at PlexConnect’s GDM to see if I can incorporate some form of it via js

Hmm, my intention was to provide a simple/secure/user friendly solution! 

But that's the whole point here, or?

I might have gotten your solution wrong here, but AFAICT, it works like this:

Your current solution will generate a plugin, that the user after downloading will need to install, and safekeep afterwards in order to unlock again....

And if your user then decides to lock another section, then the story repeats itself, except for the fact, that the bundles are named identical

As such, I've provided you with a way of simply sending an html command to the server, instead of installing bundles every time, so what am I missing here?

And regarding browser history, there's none, since it would be your js that sends the http req. to PMS.

Anyway....I'll see if I can build a proff of concept one of the next couple of days

/T