Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes and updates #15

Merged
merged 46 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
e4acf11
Removed ': mixed' for php7.4 compatibility
godsgood33 Oct 3, 2022
b69ccc1
Merge branch 'master' of https://github.com/godsgood33/plex-api
godsgood33 Oct 3, 2022
0b933d9
Fix bug in checking for result type
godsgood33 Oct 7, 2022
2549a64
Added dev phpunit for unit testing
godsgood33 Oct 8, 2022
d57e4ac
Added for unit testing
godsgood33 Oct 8, 2022
7cdf47a
Add IMDB movie agent const
godsgood33 Oct 8, 2022
267b069
Added checkResults method and refactored
godsgood33 Oct 8, 2022
886402c
Added SSL bool and docs
godsgood33 Oct 8, 2022
8316d6b
Add .env and .cache files to ignore
godsgood33 Oct 13, 2022
95d4076
Add composer script for testing
godsgood33 Oct 13, 2022
7c137c6
Cleanup
godsgood33 Oct 13, 2022
1e36879
formatting
godsgood33 Oct 13, 2022
0958264
formatting
godsgood33 Oct 13, 2022
7fb8e1b
formatting
godsgood33 Oct 13, 2022
c003263
Add section and item list
godsgood33 Oct 21, 2022
3ec7e0f
Limit tests to files ending in "Test.php"
godsgood33 Oct 21, 2022
41917f7
Added array2object method and refactored array2collection
godsgood33 Oct 21, 2022
bccd290
Update getData method to allow for other returns
godsgood33 Oct 21, 2022
8845e9e
Implement Item interface
godsgood33 Oct 21, 2022
3620be0
Add more tests
godsgood33 Oct 21, 2022
7eac623
Add SectionList and ItemList.php for testing
godsgood33 Oct 21, 2022
2e5b8a5
Add support for music libraries
godsgood33 Oct 23, 2022
1e5c8af
Update filter docs
godsgood33 Oct 23, 2022
e4273ef
Add links to Testing and Music docs
godsgood33 Oct 23, 2022
68d3cef
Add check for .env file is readable
godsgood33 Oct 23, 2022
37e1513
Add doc for array2object method
godsgood33 Oct 23, 2022
09dacae
Add testing doc
godsgood33 Oct 23, 2022
33db972
Add method to get account data and add test
godsgood33 Oct 26, 2022
14bf3d1
Add test to check for Collection Size
godsgood33 Nov 1, 2022
d57802f
Add option to return size in TB
godsgood33 Nov 1, 2022
22167e9
Doc add property doc
godsgood33 Nov 1, 2022
552056f
Add resolution as filter field
godsgood33 Nov 1, 2022
710e05f
Converted episode property to ItemCollection
godsgood33 Nov 1, 2022
5b019c5
Fixed error if only one Writer or Role
godsgood33 Nov 1, 2022
9ced516
Converted album array to ItemCollection
godsgood33 Nov 1, 2022
74f23bd
Converted track array to ItemCollection
godsgood33 Nov 1, 2022
0173f93
Add method to get size of all media in collection
godsgood33 Nov 1, 2022
2677928
Allow return Library Sections as object
godsgood33 Nov 1, 2022
cb9b06d
Update docs with getChildren method
godsgood33 Nov 1, 2022
8ffaa0b
Reformat media class list for better readability
godsgood33 Nov 1, 2022
75d077d
Fixed formatting for array2object method
godsgood33 Nov 1, 2022
c720be6
Fixed error if multiple media files for the same movie
godsgood33 Dec 23, 2022
f1cb255
Add method and docs to retrieve artwork data
godsgood33 Dec 23, 2022
bcfcc8d
Complete conversion to ItemCollection for episodes
godsgood33 Dec 23, 2022
da11003
Set minimum stability to stable and remove unncessary library
godsgood33 Dec 23, 2022
a4407c8
Fix failed login returns as suggested in issue #8
godsgood33 Dec 23, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
.idea
vendor
composer.lock
.env
*.env
*.cache
11 changes: 8 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,23 @@
"email": "[email protected]"
}
],
"minimum-stability": "dev",
"minimum-stability": "stable",
"require": {
"php": ">=7.4",
"ext-curl": "*"
},
"require-dev": {
"victorjonsson/markdowndocs": "dev-master",
"symfony/dotenv": "6.2.x-dev"
"symfony/dotenv": "6.2.x-dev",
"phpunit/phpunit": "^9"
},
"autoload": {
"psr-0": {
"jc21": "src"
}
},
"scripts": {
"test": "php vendor/bin/phpunit",
"sections": "php tests/SectionList.php",
"items": "php tests/ItemList.php"
}
}
45 changes: 45 additions & 0 deletions docs/Album.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Album

The object to represent a music album

## Property List

| Data type | Property | Description |
| :-------- | :---------------------- | :-------------------------------------------------- |
| int | ratingKey | |
| int | parentRatingKey | |
| string | key | The key to get the details of the album |
| string | parentKey | The link back to the artist |
| string | guid | |
| string | parentGuid | |
| string | studio | The studio that produced the album |
| string | type | The media type `album` |
| string | title | The title of the album |
| string | titleSort | The title used in sorting the album in the UI |
| string | parentTitle | The name of the parent artist |
| string | summary | |
| string | rating | User rating |
| int | index | |
| int | viewCount | |
| int | skipCount | |
| int | year | The year the album was released |
| DateTime | lastVeiwedAt | Date/time the album was last played |
| DateTime | originallyAvailableAt | The date/time the album was released |
| DateTime | addedAt | Date/time the album was added to the library |
| DateTime | updatedAt | Date/time the album database entry was last changed |
| string | thumb | URL to thumbnail |
| string | parentThumb | URL to artist thumbnail |
| int | loudnessAnalysisVersion | |
| array | directory | |
| array | genre | Genre's of music on the album |

## Function List

| Visibility | Function (parameters,...): return |
| :------------ | :--------------------------------------------------------------------------------------------------------------------------------------- |
| public | <strong>__construct()</strong>: <em>void</em><br /> |
| public | <strong>__get(</strong><em>string</em> <strong>$var)</strong>: <em>mixed</em><br />Magic getter |
| public | <strong>__set(</strong><em>string</em> <strong>\$var</strong>, <em>mixed</em> <strong>$val)</strong>: <em>void</em><br />Magic setter |
| public | <strong>getChildren()</strong>: <em>ItemCollection:Track</em><br />Method to retrieve collection of tracks on this album |
| public | <strong>addTrack(</strong><em>Track</em> <strong>$a)</strong>: <em>void</em> |
| public static | <strong>fromLibrary(</strong><em>array</em> <strong>$library)</strong>: <em>Album</em><br />Create a Album from the Plex API call return |
34 changes: 34 additions & 0 deletions docs/Artist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Artist

The object to represent a music artist

## Property List

| Data type | Property | Description |
| :-------- | :----------- | :-------------------------------------------------- |
| int | ratingKey | |
| string | key | The key to get the details of the artist |
| string | guid | |
| string | type | The media type `artist` |
| string | title | The artist's name |
| string | summary | |
| int | index | |
| int | viewCount | Number of times the artist details have been viewed |
| int | skipCount | |
| DateTime | lastViewedAt | Date/time somebody viewed this artist |
| DateTime | addedAt | Date/time this artist was added to the database |
| DateTime | updatedAt | Date/time this artist's database entry was updated |
| string | thumb | URL to thumbnail image |
| string | art | |
| array | genre | Genre's of music the artist has performed in |
| array | country | Country's the albums were recorded in |

## Function List
| Visibility | Function (parameters,...): return |
| :------------ | :----------------------------------------------------------------------------------------------------------------------------------------- |
| public | <strong>__construct()</strong>: <em>void</em><br /> |
| public | <strong>__get(</strong><em>string</em> <strong>$var)</strong>: <em>mixed</em><br />Magic getter |
| public | <strong>__set(</strong><em>string</em> <strong>\$var</strong>, <em>mixed</em> <strong>$val)</strong>: <em>void</em><br />Magic setter |
| public | <strong>getChildren()</strong>: <em>ItemCollection:Album</em><br />Method to retrieve all albums written by this artist |
| public | <strong>addAlbum(</strong><em>Album</em> <strong>$a)</strong>: <em>void</em> |
| public static | <strong>fromLibrary(</strong><em>array</em> <strong>$library)</strong>: <em>Artist</em><br />Create a Artist from the Plex API call return |
20 changes: 15 additions & 5 deletions docs/Documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### Main Class

[PlexApi](PlexApi.md)<br />
[PlexApi](PlexApi.md)

### Collection Classes

Expand All @@ -11,10 +11,16 @@

### Media Classes

[Movie](Movie.md)<br />
[Show](Show.md)<br />
[Season](Season.md)<br />
[Episode](Episode.md)<br />
- Movie
- [Movie](Movie.md)<br />
- TV
- [Show](Show.md)<br />
- [Season](Season.md)<br />
- [Episode](Episode.md)<br />
- Music
- [Artist](Artist.md)<br />
- [Album](Album.md)<br />
- [Track](Track.md)<br />

### Utility Classes

Expand All @@ -26,6 +32,10 @@ Item - only present for inheritance and `ItemCollection`<br />
[Size](Size.md)<br />
[Section](Section.md)

### Dev Testing

[Tests](Tests.md)

<hr />

## PlexApi
Expand Down
4 changes: 2 additions & 2 deletions docs/Filter.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Filter

This class is specifically intended to filter a library section, but could be used for other purposes. Objects are `immutable` as there are no publicly available properties or setter methods.
This class is specifically intended to filter a library section, but could be used for other purposes. Objects are `immutable` as there are no publicly available properties or setter methods. **Filters matches case-insensitive results.**

## Function List

| Visibility | Function (parameters,...): return |
|:-----------|:---------|
| :--------- | :-------------------------------- |
| public | <strong>__construct(</strong><em>string</em> <strong>$field</strong>, <em>string</em> <strong>$value</strong>, <em>string</em> <strong>$operator = `'='`)</strong>: <em>void</em> |
| public | <strong>__toString()</strong>: <em>string</em><br />Convert the object to a string |

Expand Down
11 changes: 7 additions & 4 deletions docs/PlexApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

## Function List

| Visibility | Function (parameters,...): return |
|:-----------|:---------|
| public | <strong>__construct(</strong><em>string</em> <strong>$host=`'127.0.0.1'`</strong>, <em>mixed/int</em> <strong>$port=32400</strong>, <em>bool</em> <strong>$ssl=false</strong>)</strong> : <em>void</em><br /><em>Instantiate the class with your Host/Port</em> |
| Visibility | Function (parameters,...): return |
| :--------------- | :---------------- |
| public | <strong>__construct(</strong><em>string</em> <strong>$host = `'127.0.0.1'`</strong>, <em>mixed/int</em> <strong>$port = 32400</strong>, <em>bool</em> <strong>$ssl = false</strong>)</strong> : <em>void</em><br /><em>Instantiate the class with your Host/Port</em> |
| public | <strong>getBaseInfo()</strong> : <em>array\|bool</em><br /><em>Get Plex Server basic info</em> |
| public | <strong>getAccount()</strong> : <em>array\|bool</em><br /><em>Get account info</em> |
| public | <strong>getLastCallStats()</strong> : <em>array</em><br /><em>Get last curl stats, for debugging purposes</em> |
| public | <strong>getLibrarySections()</strong> : <em>array\|bool</em><br /><em>Get Library Sections ie Movies, TV Shows etc</em> |
| public | <strong>getLibrarySectionContents(</strong><em>int</em> <strong>$sectionKey</strong>, <em>bool</em> <strong>$returnCollection = `false`)</strong> : <em>array\|ItemCollection\|bool</em><br /><em>Get Library Section contents</em> |
| public | <strong>getMetadata(</strong><em>int</em> <strong>$item</strong>)</strong> : <em>array\|bool</em><br /><em>Get Metadata for an Item</em> |
| public | <strong>getArtwork(</strong><em>Movie</em> <strong>$item</strong>, <em>string</em> <strong>$tag</strong>) : <em>string</em><br /><em>Get binary data for artwork, can store as `jpg` at return</em> |
| public | <strong>getOnDeck(</strong><em>bool</em> <strong>$returnCollection = `false`)</strong> : <em>array\|ItemCollection\|bool</em><br /><em>Get On Deck Info</em> |
| public | <strong>getRecentlyAdded(</strong><em>bool</em> <strong>$returnCollection = `false`)</strong> : <em>array\|ItemCollection\|bool</em><br /><em>Get Recently Added</em> |
| public | <strong>getServers()</strong> : <em>array\|bool</em><br /><em>Get Servers</em> |
Expand All @@ -31,4 +33,5 @@
| private | <strong>buildHttpQuery(</strong><em>array</em> <strong>$query)</strong>: <em>string</em><br /><em>Build http query string from array of `Filter` objects</em> |
| protected static | <strong>normalizeSimpleXML(</strong><em>mixed</em> <strong>$obj</strong>, <em>mixed</em> <strong>$result</strong>)</strong> : <em>void</em><br /><em>normalizeSimpleXML</em> |
| protected static | <strong>xml2array(</strong><em>mixed</em> <strong>$xml</strong>)</strong> : <em>mixed</em><br /><em>xml2array</em> |
| public static | <strong>array2Collection(</strong><em>array</em> <strong>$array)</strong>: <em>ItemCollection</em> |
| public static | <strong>array2collection(</strong><em>array</em> <strong>$array)</strong>: <em>ItemCollection</em> |
| public static | <strong>array2object(</strong><em>array</em> <strong>$array)</strong>: <em>Movie\|Show\|Season\|Episode\|Artist\|Album\|Track</em> |
4 changes: 2 additions & 2 deletions docs/Season.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ This represents a single season within a show
| int | viewedLeafCount | The number of times an episode in this season was viewed |
| `DateTime` | addedAt | The date and time this season was added to the library |
| `DateTime` | updatedAt | The date and time this season was last updated in the library |
| array:[Episode](Episode.md) | episodes | An array to store all the episodes in this season |
| `ItemCollection`:`Episode`(Episode.md) | episodes | An array to store all the episodes in this season |

## Function List

Expand All @@ -35,6 +35,6 @@ This represents a single season within a show
| public | <strong>__construct()</strong>: <em>void</em><br /> |
| public | <strong>__get(</strong><em>string</em> <strong>$var)</strong>: <em>mixed</em><br />Magic getter |
| public | <strong>__set(</strong><em>string</em> <strong>$var</strong>, <em>mixed</em> <strong>$val)</strong>: <em>void</em><br />Magic setter |
| public | <strong>getEpisodes()</strong>: <em>array:Episodes</em><br />Method to get all episodes within this season |
| public | <strong>getChildren()</strong>: <em>ItemCollection:Episodes</em><br />Method to get all episodes within this season |
| public | <strong>addEpisode(</strong><em>Episode</em> <strong>$episode)</strong>: <em>void</em><br />Method to add an episode to the season |
| public static | <strong>fromLibrary(</strong><em>array</em> <strong>$lib)</strong>: <em>Season</em><br />Method to create a season |
4 changes: 2 additions & 2 deletions docs/Show.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ A TV Show
| string | audienceRatingImage | |
| array:string | genre | The genres the show is in |
| array:string | role | The actor/actresses in the show |
| array:[Season](Season.md) | seasons | The array containing all the seasons |
| `ItemCollection`:`Season`(Season.md) | seasons | The array containing all the seasons |

## Function List

Expand All @@ -43,6 +43,6 @@ A TV Show
| public | <strong>__construct()</strong>: <em>void</em><br /> |
| public | <strong>__get(</strong><em>string</em> <strong>$var)</strong>: <em>mixed</em><br />Magic getter |
| public | <strong>__set(</strong><em>string</em> <strong>$var</strong>, <em>mixed</em> <strong>$val)</strong>: <em>void</em><br />Magic setter |
| public | <strong>getSeasons()</strong>: <em>array:Season</em><br />Method to get the seasons |
| public | <strong>getChildren()</strong>: <em>array:Season</em><br />Method to get the seasons |
| public | <strong>addSeason(</strong><em>Season</em> <strong>$season)</strong>: <em>bool</em><br />Method to add a season to the show |
| public static | <strong>fromLibrary(</strong><em>array</em> <strong>$lib)</strong>: <em>Show</em><br />Method to create a show from the Plex API call |
33 changes: 33 additions & 0 deletions docs/Tests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Tests

## Intro

PHPUnit is added for development purposes to be able to perform unit tests and make sure that all functions operate as expected. To accomplish this an `.env` file needs to be created in the `/tests` folder with the following information:

| **Env** | **Value** | **Description** |
| ---------------------- | -------------- | -------------------------------------------------------------------------- |
| **PLEX_HOST** | *ip\|hostname* | IP or host name of the Plex server |
| **PLEX_PORT** | *port* | Port to connect to Plex server (optional, defaults 32400) |
| **PLEX_USER** | *email* | Username to login to Plex.tv (only needed once) |
| **PLEX_PASSWORD** | *password* | Password to login to Plex.tv (only needed once) |
| **PLEX_SSL** | *0\|1* | Boolean to connect to Plex server over SSL |
| **MOVIE_TESTS** | *0\|1* | Boolean to conduct tests on movie library (optional) |
| **MOVIE_SECTION_KEY** | *int* | Integer of movie library (run `composer sections` to see list |
| **MOVIE_ITEM_ID** | *int* | Integer key of a specific movie to pull metadata for |
| **MOVIE_SEARCH_QUERY** | *string* | String query to search for in Movie library |
| **MOVIE_FILTER_QUERY** | *string* | String query to filter for in Movie library (must be a 'title') |
| **TV_TESTS** | *0\|1* | Boolean to conduct tests of TV library (optional) |
| **TV_SECTION_KEY** | *int* | Integer of TV library (run `composer sections` to see list) |
| **TV_ITEM_ID** | *int* | Integer key of a specific TV show, season, or episode to pull metadata for |
| **TV_SEARCH_QUERY** | *string* | String query to search for in TV library |
| **TV_FILTER_QUERY** | *string* | String query to filter for in TV library (must be 'title') |
| **MUSIC_TESTS** | *0\|1* | Boolean to conduct tests of Music library (optional) |
| **MUSIC_SECTION_KEY** | *int* | Integer of Music library (run `composer sections` to see list |
| **MUSIC_SEARCH_QUERY** | *string* | String query to search for in Music library |
| **MUSIC_FILTER_QUERY** | *string* | String query to filter for in Music library |

The `PLEX_*` values are required. The username and password values can be deleted after the token is retrieved

`*_TESTS` are optional, if they are not present, those tests will not be run. If they are present, then the similar ENV values are required.

Once you have the PLEX_* values present you can run `composer sections` to retrieve the section keys for your libraries. Put in the section keys for the tests you want to run. After you've made the changes, run `composer test` to run php tests
Loading