Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

plex-ruby

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

plex-ruby - rubygems Package Compare versions

Comparing version
1.5.1
to
1.5.2
+9
lib/plex-ruby/config.rb
module Plex
class Config
attr_accessor :auth_token
def initialize
@auth_token = nil
end
end
end
require 'test_helper'
describe Plex::Config do
it "should be configurable" do
Plex.config.auth_token.must_equal nil
Plex.configure do |config|
config.auth_token = "ABCD"
end
Plex.config.auth_token.must_equal "ABCD"
end
end
+1
-0

@@ -6,1 +6,2 @@ *.gem

pkg/*
*.swp

@@ -0,1 +1,4 @@

## 1.5.2
* Added support for authentication token via `Plex.configure`
## 1.5.1

@@ -2,0 +5,0 @@ * `Plex::Video` now supports multiple media entries (`@media` renamed to `@medias`)

@@ -7,2 +7,26 @@ require 'nokogiri'

# Instantiates a Config instance once and returns it
def self.config
@config ||= Config.new
end
# Allows the configuration of some Plex-internal settings. It yields a Config
# instance so a block can be used:
#
# Plex.configure do |config|
# config.auth_token = "ABCDEF"
# end
def self.configure
yield(config)
end
# Custom open func which adds the required headers configured by
# <tt>Plex.configure</tt>
def self.open(url)
headers = {}
headers["X-Plex-Token"] = config.auth_token if config.auth_token
super(url, headers)
end
# Converts camel case names that are commonly found in the Plex APIs into

@@ -33,2 +57,3 @@ # ruby friendly names. I.E. <tt>playMedia</tt> -> <tt>play_media</tt>

require 'plex-ruby/config'
require 'plex-ruby/parser'

@@ -35,0 +60,0 @@ require 'plex-ruby/server'

+5
-5
module Plex
class Client
NAV_METHODS = %w(moveUp moveDown moveLeft moveRight pageUp pageDown nextLetter
previousLetter select back contextMenu toggleOSD)
NAV_METHODS = %w(moveUp moveDown moveLeft moveRight pageUp pageDown nextLetter
previousLetter select back contextMenu toggleOSD)
PLAYBACK_METHODS = %w(play pause stop rewind fastForward stepForward
PLAYBACK_METHODS = %w(play pause stop rewind fastForward stepForward
bigStepForward stepBack bigStepBack skipNext skipPrevious)

@@ -67,3 +67,3 @@

if !key.is_a?(String) && key.respond_to?(:key)
key = key.key
key = key.key
end

@@ -141,3 +141,3 @@

def ping(url)
!!open(url).read
!!Plex.open(url).read
rescue => e

@@ -144,0 +144,0 @@ puts "Error trying to ping #{url} - #{e.message}"

@@ -17,3 +17,3 @@ module Plex

end
# Delegates all method calls to the video object that represents this

@@ -59,3 +59,3 @@ # episode, if that video object responds to the method.

def xml_doc
@xml_doc ||= Nokogiri::XML( open(url+key) )
@xml_doc ||= Nokogiri::XML( Plex.open(url+key) )
end

@@ -62,0 +62,0 @@

@@ -76,3 +76,3 @@ module Plex

def base_doc
Nokogiri::XML( open(url+key) )
Nokogiri::XML( Plex.open(url+key) )
end

@@ -79,0 +79,0 @@

@@ -49,3 +49,3 @@ module Plex

def xml_doc
@xml_doc ||= Nokogiri::XML( open(url+key) )
@xml_doc ||= Nokogiri::XML( Plex.open(url+key) )
end

@@ -52,0 +52,0 @@

@@ -5,4 +5,4 @@ module Plex

ATTRIBUTES = %w(ratingKey guid type title summary index thumb leafCount
viewedLeafCount addedAt updatedAt)
ATTRIBUTES = %w(ratingKey guid type title summary index thumb leafCount
viewedLeafCount addedAt updatedAt)

@@ -83,7 +83,7 @@ attr_reader :show, :key, :attribute_hash

def base_doc
Nokogiri::XML( open(url+key) )
Nokogiri::XML( Plex.open(url+key) )
end
def base_children_doc
Nokogiri::XML( open(url+key+'/children') )
Nokogiri::XML( Plex.open(url+key+'/children') )
end

@@ -95,3 +95,3 @@

def children
def children
@children ||= base_children_doc

@@ -98,0 +98,0 @@ end

@@ -28,3 +28,3 @@ module Plex

# Returns a list of shows or movies that are in this Section.
# Returns a list of shows or movies that are in this Section.
#

@@ -42,3 +42,3 @@ # all - all videos in this Section

def #{Plex.underscore(method)}
Plex::Parser.new( self, Nokogiri::XML(open(url+key+'/#{method}')) ).parse
Plex::Parser.new( self, Nokogiri::XML(Plex.open(url+key+'/#{method}')) ).parse
end

@@ -56,3 +56,3 @@ )

# Example:
#
#
# library.section(2).by_year(2008) # List of TV Shows from 2008

@@ -77,3 +77,3 @@ # library.section(1).by_first_character("H") # movies starting with 'H'

def by_#{Plex.underscore(method)}(val)
Plex::Parser.new( self, Nokogiri::XML(open(url+key+"/#{method}/\#{val}")) ).parse
Plex::Parser.new( self, Nokogiri::XML(Plex.open(url+key+"/#{method}/\#{val}")) ).parse
end

@@ -87,3 +87,3 @@ )

end
# @private

@@ -111,3 +111,3 @@ def url #:nodoc:

def grab_keys(action)
Nokogiri::XML(open(url+key+"/#{action}")).search('Directory').map do |node|
Nokogiri::XML(Plex.open(url+key+"/#{action}")).search('Directory').map do |node|
{

@@ -114,0 +114,0 @@ key: node.attr('key'),

@@ -19,3 +19,3 @@ module Plex

# The Plex clients that are connected to this Server
#
#
# @return [Array] list of Clients connected to this server

@@ -44,3 +44,3 @@ def clients

def clients_base
Nokogiri::XML( open(url+'/clients') )
Nokogiri::XML( Plex.open(url+'/clients') )
end

@@ -47,0 +47,0 @@

module Plex
class Show
ATTRIBUTES = %w(ratingKey guid studio type title contentRating summary index
rating year thumb art leafCount viewedLeafCount addedAt
ATTRIBUTES = %w(ratingKey guid studio type title contentRating summary index
rating year thumb art leafCount viewedLeafCount addedAt
updatedAt)

@@ -47,3 +47,3 @@

# Helper method for selecting the special Season of this show
# Season 0 is where Plex stores episodes that are not part of a
# Season 0 is where Plex stores episodes that are not part of a
# regular season. i.e. Christmas Specials

@@ -109,7 +109,7 @@ #

def base_doc
Nokogiri::XML( open(url+key) )
Nokogiri::XML( Plex.open(url+key) )
end
def children_base
Nokogiri::XML( open(url+key+'/children') )
Nokogiri::XML( Plex.open(url+key+'/children') )
end

@@ -120,3 +120,3 @@

end
def children

@@ -123,0 +123,0 @@ @children ||= children_base

module Plex
VERSION = "1.5.1"
VERSION = "1.5.2"
end

@@ -27,2 +27,13 @@ # Plex-Ruby [![Build Status](https://secure.travis-ci.org/ekosz/Plex-Ruby.png)](https://secure.travis-ci.org/ekosz/Plex-Ruby)

## Configuration
For external access to your Plex Media Server an auth token is required. You
can configure it with the following snippet.
```ruby
Plex.configure do |config|
config.auth_token = "ABCDEFGH"
end
```
## Usage

@@ -29,0 +40,0 @@

@@ -11,2 +11,17 @@ require 'test_helper'

before do
FakeWeb.register_uri(:get, "http://localhost:32400", :body => "")
end
after do
FakeWeb.clean_registry
Plex.config.auth_token = nil
end
it "has an open function which respects the configuration" do
Plex.configure {|config| config.auth_token = "ABCD" }
Plex.open("http://localhost:32400").read
FakeWeb.last_request["X-Plex-Token"].must_equal "ABCD"
end
end