Skip to content

Commit

Permalink
Merge pull request #15 from godsgood33/master
Browse files Browse the repository at this point in the history
Fixes and updates
  • Loading branch information
jc21 authored Jun 7, 2023
2 parents 9837816 + a4407c8 commit b65d561
Show file tree
Hide file tree
Showing 29 changed files with 1,520 additions and 110 deletions.
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": "jc@jc21.com"
}
],
"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

0 comments on commit b65d561

Please sign in to comment.