Random sections of plex info.

Info on plugins

Plex installs its plugins to a folder, plugins show up as channels within your Media Manager

https://support.plex.tv/hc/en-us/articles/201106098-How-do-I-find-the-Plug-Ins-folder-

https://support.plex.tv/hc/en-us/articles/201187656-How-do-I-manually-install-a-channel-

To ensure correct install of plugin: make sure plugin folder ends with .bundle, and you see a folder inside the .bundle folder thats called Contents. Then reload the Media Manager and your plugin should appear as a Channel box.

By example I will show how to install a plugin below.

Unsupported Appstore Plugin (The Plugin Repository)

The coolest and biggest list of plugins can come actually from 1 plugin. This plugin is like an app store of plugins (free plugins):

https://github.com/mikedm139/UnSupportedAppstore.bundle

To install it, go to the link, download the ZIP, extract it, make sure the folder name is UnSupportedAppstore.bundle (in other words remove the -master suffix from the folder name). You know you have it correctly structured, if you go into the folder UnsupportedAppstore.bundle and you see another folder called Contents.

Look at how its installed in my windows plex setup (I have Plex installed to F:\Programs0\PlexData\Plex Media Server\Plug-ins)

Above is the folder when you right click on the plex icon and click Open Plugins folder.

I think the rest is pretty straight forward. This is how they appear in plex. Open up your Media Manager

Note: above is what I see when I right click on the Plex Icon, notice the Media Manager and the Open Plugins Folder 

Then click on the Channels link

You will see all of your plugins (might take a few moments/ refreshes/relogins to see them)

There is no shame in showing my plugins:

Plexdoops – Plex-Duplicates – Find Duplicates

UPDATE: 2015-09-23 doesnt work on latest plex anymore probably because changes authentication scheme or something or that fact that you can have your server encrypted now

And all different approach to plugins, is making your own apps via other programming languages (such as ruby) to interact with plex.

Here is an app thats called Plex-Duplicates that will login to a Plex server and find all of the duplicates.

You can use the same PC or another PC (as long as it has access to the port 32400 of plex). You must install the latest ruby (it worked with 2.1.2 for me – currently I see 2.1.4, it should work with that as well I suppose)

https://github.com/pstadler/plex-duplicates

This uses ruby bundler, more info on that (its like pip for python):

http://bundler.io/

Bundler provides a consistent environment for Ruby projects by tracking and installing the exact gems and versions that are needed.

Gems are packages in ruby

http://heatware.net/ruby-rails/how-to-install-rubygems-linux-ubuntu-10/

https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-on-ubuntu-12-04-lts-precise-pangolin-with-rvm

Update on plex-duplicates (I made a small edit). The normal script didnt have a save option and if you redirected to a file, it would be filled with alot of binary data that has to do with the page always being cleared because the output for the progress uses “print” (which keeps printing on the same line). I changed the output of the progress to stderr using puts, and that gives it a scrolling effect, but the main reason i did it is not for the scrolls (because the scrolls look terrible), its so that you can have good normal output. Here is my plex-doops script below.

#############################################
# PLEX-DUPLICATES / PLEXDOOPS INSTALL STEPS #
#############################################

apt-get update

# install ruby 1.9 (also I tested with ruby 2.x and it works)
apt-get install ruby-full

# download the bundler software which takes care of ruby app dependencies - http://bundler.io/
gem install bundler

# pick a folder to install ruby to (I picked /root as im root user, more on this later)
cd /root
git clone https://github.com/pstadler/plex-duplicates
mv duplicates plexdoops
cd plexdoops

# now we are in /root/plexdoops

# install the dependencies/Gems of plex-duplicates (it reads the Gemfile & Gemfile.lock files that are there to find out what to install to meet the requirements of this plexdoops app)
bundle install

# * note its never a good idea to run random software as root user, however this is on a system that I dont mind running as root. but if you dont want to run as root thats fine. in fact bundle install insists that you dont run anything as root, and it warns that it might error out if you run as root. well, in my case it did not error out when i run it as root. in fact everything went well. note I didnt run as sudo from another user, i was simply root the whole time.

# --- install is now complete --- #

##################
# RUN PLEX-DOOPS #
##################

# now run the app to scan and output the duplicates

# all you need to do is fill in the hostname or ip of the plex server and optionally set the port by defaults its port 32400. eg: './duplicates.rb localhost' or './duplicates.rb 10.11.12.13:32400' or './duplicates.rb 10.11.12.13:40000'
./duplicates.rb <hostname>[:port]

# another way to run this app is with a wrapper script that outputs to files which would be useful to run as a scheduled task with cron, that way you can keep track of your duplicates
# my wrapper script uses dos2unix package which has unix2dos as well so that file has correct lines when viewed from windows. unix2dos package contains software that converts text files with end-of-lines of unix to dos, and vice versa.
apt-get install dos2unix
# make the wrapper script which i call pdcron.sh, its contents are below
vi pdcron.sh
# once its made you test run it (its results go into a subfolder in plexdoops, see the script to see where plexdoops results are saved to - of course you can edit the script if you want things saved else where)
./pdcron.sh
# now we will set this to run on a schedule so that we can keep track of the duplicates. you can edit your scheduled cron tasks so that this runs once a day or however often you want it (i just run once a week, every sunday at 11:45 pm after all the shows run).
crontab -e
#  crontab -e will open you crontab editor, at the very bottom just put this line "23 45 * * 0 /root/plexdoops/pdcron.sh" (more on this below). exit and save
# verify you see your entry with crontab -l
crontab -l

If you were interested in the contents of the duplicates .rb code, this one includes my edits: /root/plexdoops/duplicates.rb

#!/usr/bin/env ruby
require 'rubygems'
require 'bundler'
Bundler.require(:default, (ENV['RACK_ENV'] ||= :development.to_s).to_sym)

host, port = (ARGV[0] || '').split(':')
host ||= 'localhost'
port ||= 32400

def pretty_filesize n
  count = 0
  while  n >= 1024 and count < 4
    n /= 1024.0
    count += 1
  end
  format("%.2f",n) + %w(B KB MB GB TB)[count]
end

puts "Connecting to #{host}:#{port}"
server = Plex::Server.new(host, port)

server.library.sections.each do |section|
  case section.type
  when 'show' then
    videos = []
    section.all.each do |s|
      s.seasons.each do |m|
        m.episodes.each do |e|
          videos << e
        end
      end
    end
  when 'movie' then
    videos = section.all
  else
    next
  end
   # infotinks edit, commented out line below and added the line below that starting with $stderr - so that we can have nice redirectable/saveable output
  # print "Analyzing #{section.title.white}: 0/#{videos.length}"
  $stderr.puts "Analyzing #{section.title.white}: 0/#{videos.length}"
  out = ''
  videos.each_with_index do |item, index|
    if not ['movie', 'episode'].include?(item.type)
      next
    end

    medias = item.medias
    if medias.length > 1
      out << "#{item.grandparent_title + ': ' if item.type == 'episode'}#{item.title}\n".white
      last_dir = nil
      medias.each do |m|
        m.parts.each do |part|
          dir = File.dirname(part.file)
          name = File.basename(part.file)
          size = pretty_filesize(part.size.to_i)
          unless last_dir.nil? or last_dir == dir
            out << "  #{dir.red}/#{name} (#{size})\n"
          else
            out << "  #{part.file} (#{size})\n"
          end
          last_dir = dir
        end
      end
    end
    # infotinks edit, commented out line below and added the line below that starting with $stderr - so that we can have nice redirectable/saveable output
    # print "\rAnalyzing #{section.title.white}: #{index+1}/#{videos.length}"
    $stderr.puts "\rAnalyzing #{section.title.white}: #{index+1}/#{videos.length}"
  end
  puts "\n\n#{out}\n"
end

Here is my pdcron.sh file. I run this in a cron job bash script file:

#!/bin/bash
# filename: /root/plexdoops/pdcron.sh
# What this does: start plex dups for cron - doesnt require any args
# I use subshell so that the "cd" command doesnt affect my normal work flwo
(
# cd is needed. Need to go to the directory or else it doesnt work due to gem bundling or something or other
cd /root/plexdoops/
# set vars
PLEXDOOPS="/root/plexdoops/duplicates.rb"
# I put my PCs IP where I have my plex server, if my plex is running on a different port, such as 9999, I can put this instead: TARGETIPANDPORT="192.168.1.5 9999" 
TARGETIPANDPORT="192.168.1.5"
RESDIR="/root/plexdoops/results"
OUT1="${RESDIR}/PLEX-DUP-RESULTS-CEO-`date +%Y_%m_%d_s%s`.txt"
OUT2="${RESDIR}/PLEX-DUP-RESULTS-CEO-`date +%Y_%m_%d_s%s`-ERROR.txt"
# run the main task
mkdir -p ${RESDIR}
${PLEXDOOPS} ${TARGETIP} 2>${OUT2} > ${OUT1}
# convert the output so that windows PC can see it, below 2 lines are optional but dont forget the closing parenthesis since we opened up the subshell with the open parenthesis up top
/usr/bin/unix2dos ${OUT1}
/usr/bin/unix2dos ${OUT2}
)

And here is my cronjob list looks like this:

# To see cronjob list:
crontab -l

# To edit cronjob list:
crontab -e

# Here is the inside of that file:

# m h  dom mon dow   command
# run plex doops to find plex duplicates (11:45 pm every sunday)
23 45 * * 0 /root/plexdoops/pdcron.sh

Test run it with /root/plexdoops/pdcron.sh and results should be in /root/plexdoops/results. Also can test run with running the ruby script /root/plexdoops/duplicates.rb TARGETIP TARGETPORT, like this /root/plexdoops/duplicates.rb 192.168.1.5 9999 or like this /root/plexdoops/duplicates.rb 192.168.1.5 (if your using the 32400 normal port of plex)

Here is everything in a zip file (including the original duplicates.rb and my edits): Plexdoops-by-infotinks  <- this doesnt contain ruby or bundler or any of the dependencies that gemfile gets. you will need to get those your self with apt-get and bundle (using my instructions above – as they get everything)

3 thoughts on “Plex Plugins & Unsupported AppStore Plugin & Plex-Duplicates/Plexdoops

  1. New to Plex… Thanks for your article. I’m writing here because you said it may be sooner-noticed than an email would be.

    Do you have any insight into an API/SDK? My motivation is to create a search function to search channels that are in the Unsupported bundle. The links I have found (dev.plex.tv) no longer seem to exist and the official Plex website doesn’t seem geared toward devs/providers at all.

    Thought you might be a good person to ask. No sweat if you don’t know. Thanks either way!

Leave a Reply

Your email address will not be published. Required fields are marked *