Giter VIP home page Giter VIP logo

plex-ruby's Introduction

Plex-Ruby Build Status

A handy gem for working with Plex Media Player within Ruby. Tries to emulate and document all of the Plex APIs using simple ruby code. I will try and keep it as up-to-date as possible, but pull requests are always welcomed.

Installation

Add to your Gemfile and run the bundle command

gem 'plex-ruby'

Or

gem install plex-ruby

require 'plex-ruby'

I developed this using Ruby 1.9.2 so no guaranties that it will work with lesser versions of Ruby.

Configuration

For external access to your Plex Media Server an auth token is required. You can configure it with the following snippet.

Plex.configure do |config|
  config.auth_token = "ABCDEFGH"
end

Usage

Everything Stems from the Plex Media Server. Create a server with the host and port number.

server = Plex::Server.new(CONFIG[:host], CONFIG[:port])

From here we can start doing cool things. Lets pause whats currently playing.

clients = server.clients  # list of all connected clients
client =                  # pick the media player you want
client.pause              # That was easy

Lets search the libary.

sections = server.library.sections
section =                                           # Pick the section you want I.E. TV, Movies, Home Videos
shows = section.all                                 # Returns a list of shows/movies
bsg = shows.detect { |s| s.title =~ /Battlestar/ }  # Pick a great show
season = bsg.last_season                            # Pick the last season
episode = season.episode(5)                         # The fifth episode in the season
puts "#{episode.title} - #{episode.summary}"        # Looks good
client.play_media(episode)                          # Play it!

You can also use the attribute_hash method on an object to get a full list of attributes.

pp episode.attribute_hash
#=>
#{"rating_key"=>"23",
# "key"=>"/library/metadata/23",
# "guid"=>"com.plexapp.agents.thetvdb://73545/1/13?lang=en",
# "type"=>"episode",
# "title"=>"Kobol's Last Gleaming (2)",
# "summary"=>
#  "When Commander Adama learns that Kara disobeyed orders and Jumped to Caprica on orders from President Roslin, he demands the president's resignation, with the implied threat of a military coup. Roslin refuses his demand and sparks a confrontation.",
# "index"=>"13",
# "rating"=>"8.3",
# "year"=>"2005",
# "thumb"=>"/library/metadata/23/thumb?t=1323220437",
# "originally_available_at"=>"2005-01-24",
# "added_at"=>"1323213639",
# "updated_at"=>"1323220437"}

For a full list of commands check out the documentation.

Development

All development of this gem takes place on its GitHub page. There you can create issues or submit pull requests.

When submiting a pull request please write tests for your changes as well as use feature branches. Thank you!

This gem was created by Eric Koslow and is under the MIT Licence.

plex-ruby's People

Contributors

ekosz avatar jodyalbritton avatar pboehm avatar pstadler avatar rueckstiess avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

plex-ruby's Issues

Clients array is always empty

I have tried to use plex-ruby as such:

server = Plex::Server.new("server.url", 32400)

server.clients
=> [ ]
server.library.sections (works properly)
=> [#<Plex::Section: key="/library/sections/3" type="show" title="Anime">, #<Plex::Section: key="/library/sections/1" type="movie" title="Movies">, #<Plex::Section: key="/library/sections/2" type="show" title="TV Shows">]

Better support for accessing stream types.

Add better support for accessing stream types, like video, audio, and subtitles.

For example on this movie the streams section of the XML looks like this:

<Stream id="352782" streamType="1" default="1" codec="h264" index="0" bitrate="12993" language="English" languageCode="eng" bitDepth="8" chromaLocation="left" chromaSubsampling="4:2:0" frameRate="23.976" hasScalingMatrix="0" height="816" level="41" profile="high" refFrames="5" requiredBandwidths="35655,31724,25768,23725,21919,20284,16697,16697" scanType="progressive" title="13993 kbps" width="1920" displayTitle="1080p (H.264)"/>
<Stream id="352783" streamType="2" selected="1" default="1" codec="dca" index="1" channels="6" bitrate="1509" language="English" languageCode="eng" audioChannelLayout="5.1(side)" bitDepth="24" profile="dts" requiredBandwidths="1509,1509,1509,1509,1509,1509,1509,1509" samplingRate="48000" title="Main Audio" displayTitle="English (DTS 5.1)"/>
<Stream id="352784" streamType="2" codec="aac" index="2" channels="2" bitrate="70" language="English" languageCode="eng" audioChannelLayout="stereo" profile="he-aac" requiredBandwidths="71,71,71,71,71,71,71,71" samplingRate="48000" title="Commentary" displayTitle="English (HE-AAC Stereo)"/>
<Stream id="352785" streamType="3" selected="1" default="1" codec="srt" index="3" bitrate="0" language="English" languageCode="eng" requiredBandwidths="1,1,1,1,1,1,1,1" title="srt" displayTitle="English (SRT)"/>
<Stream id="352786" streamType="3" codec="srt" index="4" bitrate="0" language="中文" languageCode="chi" requiredBandwidths="1,1,1,1,1,1,1,1" title="srt" displayTitle="中文 (SRT)"/>

And I'd love a way to do something like: movie.streams.audios or something and have it return these two entries in an array of two objects of audio class or something to that effect:

<Stream id="352783" streamType="2" selected="1" default="1" codec="dca" index="1" channels="6" bitrate="1509" language="English" languageCode="eng" audioChannelLayout="5.1(side)" bitDepth="24" profile="dts" requiredBandwidths="1509,1509,1509,1509,1509,1509,1509,1509" samplingRate="48000" title="Main Audio" displayTitle="English (DTS 5.1)"/>
<Stream id="352784" streamType="2" codec="aac" index="2" channels="2" bitrate="70" language="English" languageCode="eng" audioChannelLayout="stereo" profile="he-aac" requiredBandwidths="71,71,71,71,71,71,71,71" samplingRate="48000" title="Commentary" displayTitle="English (HE-AAC Stereo)"/>

Note that audio is streamType="2" so that should be pretty straight forward, however I was thinking about how to implement this and it would make sense to break each stream type out into its own class, but herein lies the problem. streamType="1" is video and there is already a Video class, so I'm not sure how to go about doing this. What are the thoughts on the best way to tackle this?

Would it be best to leave video out of it and just do audio and subtitles? Or would it be best to name them like StreamVideo, StreamAudio, and StreamSubtitle, though that seems a bit awkward and not super discoverable.

Error trying to ping server when trying to play_media

Everything seems to be functioning fine except when I actually try to play a movie using client.play_media(). It gives the following message...
Error trying to ping http://10.0.1.124:32400/system/players/machine name/application/playMedia?path=http%3A%2F%2F10.0.1.124%3A32400%2Flibrary%2Fmetadata%2F445&key=%2Flibrary%2Fmetadata%2F445 - 500 Internal Server Error

Not sure if it is a issue or if I am doing something wrong. I can pull all other info from the server as the instructions state. But .play_media() gives me that error. Can someone chime in and give me a little help. I would really appreciate it. Thank you.

Documentation

Needs documentation written. Might be hard to document to write method documentation for those methods that are mass defined through class_evals.

Tag new release

Hey,

Could you take a new release with the new auth_token stuff please.

Thanks

Tests

I need to stop being lazy and write tests.

Create Refresh Methods

Currently many values are stored in instance variable caches that are loaded once and then stored after words.

If the contents of a library changed, or another client connected there is no easy way to grab that new data without restarting the program.

I propose adding methods like server.clients! and server. library.sections! that will override those instance caches.

Show attribute to correlate to thetvdb seriesId?

Hi,

I was thinking of using your gem to write something that would check my library of tv shows, and verify they are up to date via the thetvdb. Does any of the information you can pull out of Plex library match the thetvdb series ID?

Thanks!

Redo Plex.url

Currently many classes need to reference Plex.url to find the base url for the Plex Media Server. This does not allow for multiple servers to be instantiated, as each one overrides the Plex.url variable.

One proposed way to do this is to have every object reference its parent, all the way back the the server object they all came from.

For example,

episode.season.show.section. library.server.base_url 

This would solve the problem, but I feel there could be a less verbose way to go about it.

Add compatibility for collections.

Collections are an attribute that can be returned from movies. It would be really nice to get collections the same way other tags are.

For example, movie.collections would return:

<Collection id="78376" filter="collection=78376" tag="Captain America"/>

in an array, as a collection class.

Spaces in player name

Are you still maintaining this gem?

The player names should be escaped for spaces.

Web interface

Can it be used for web conferencing? If not can this feature be added like wowza media server?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.