Skip to content

Commit b65d561

Browse files
authored
Merge pull request #15 from godsgood33/master
Fixes and updates
2 parents 9837816 + a4407c8 commit b65d561

29 files changed

+1520
-110
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
.idea
33
vendor
44
composer.lock
5-
.env
5+
*.env
6+
*.cache

composer.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,23 @@
1414
"email": "jc@jc21.com"
1515
}
1616
],
17-
"minimum-stability": "dev",
17+
"minimum-stability": "stable",
1818
"require": {
1919
"php": ">=7.4",
2020
"ext-curl": "*"
2121
},
2222
"require-dev": {
23-
"victorjonsson/markdowndocs": "dev-master",
24-
"symfony/dotenv": "6.2.x-dev"
23+
"symfony/dotenv": "6.2.x-dev",
24+
"phpunit/phpunit": "^9"
2525
},
2626
"autoload": {
2727
"psr-0": {
2828
"jc21": "src"
2929
}
30+
},
31+
"scripts": {
32+
"test": "php vendor/bin/phpunit",
33+
"sections": "php tests/SectionList.php",
34+
"items": "php tests/ItemList.php"
3035
}
3136
}

docs/Album.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Album
2+
3+
The object to represent a music album
4+
5+
## Property List
6+
7+
| Data type | Property | Description |
8+
| :-------- | :---------------------- | :-------------------------------------------------- |
9+
| int | ratingKey | |
10+
| int | parentRatingKey | |
11+
| string | key | The key to get the details of the album |
12+
| string | parentKey | The link back to the artist |
13+
| string | guid | |
14+
| string | parentGuid | |
15+
| string | studio | The studio that produced the album |
16+
| string | type | The media type `album` |
17+
| string | title | The title of the album |
18+
| string | titleSort | The title used in sorting the album in the UI |
19+
| string | parentTitle | The name of the parent artist |
20+
| string | summary | |
21+
| string | rating | User rating |
22+
| int | index | |
23+
| int | viewCount | |
24+
| int | skipCount | |
25+
| int | year | The year the album was released |
26+
| DateTime | lastVeiwedAt | Date/time the album was last played |
27+
| DateTime | originallyAvailableAt | The date/time the album was released |
28+
| DateTime | addedAt | Date/time the album was added to the library |
29+
| DateTime | updatedAt | Date/time the album database entry was last changed |
30+
| string | thumb | URL to thumbnail |
31+
| string | parentThumb | URL to artist thumbnail |
32+
| int | loudnessAnalysisVersion | |
33+
| array | directory | |
34+
| array | genre | Genre's of music on the album |
35+
36+
## Function List
37+
38+
| Visibility | Function (parameters,...): return |
39+
| :------------ | :--------------------------------------------------------------------------------------------------------------------------------------- |
40+
| public | <strong>__construct()</strong>: <em>void</em><br /> |
41+
| public | <strong>__get(</strong><em>string</em> <strong>$var)</strong>: <em>mixed</em><br />Magic getter |
42+
| public | <strong>__set(</strong><em>string</em> <strong>\$var</strong>, <em>mixed</em> <strong>$val)</strong>: <em>void</em><br />Magic setter |
43+
| public | <strong>getChildren()</strong>: <em>ItemCollection:Track</em><br />Method to retrieve collection of tracks on this album |
44+
| public | <strong>addTrack(</strong><em>Track</em> <strong>$a)</strong>: <em>void</em> |
45+
| public static | <strong>fromLibrary(</strong><em>array</em> <strong>$library)</strong>: <em>Album</em><br />Create a Album from the Plex API call return |

docs/Artist.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Artist
2+
3+
The object to represent a music artist
4+
5+
## Property List
6+
7+
| Data type | Property | Description |
8+
| :-------- | :----------- | :-------------------------------------------------- |
9+
| int | ratingKey | |
10+
| string | key | The key to get the details of the artist |
11+
| string | guid | |
12+
| string | type | The media type `artist` |
13+
| string | title | The artist's name |
14+
| string | summary | |
15+
| int | index | |
16+
| int | viewCount | Number of times the artist details have been viewed |
17+
| int | skipCount | |
18+
| DateTime | lastViewedAt | Date/time somebody viewed this artist |
19+
| DateTime | addedAt | Date/time this artist was added to the database |
20+
| DateTime | updatedAt | Date/time this artist's database entry was updated |
21+
| string | thumb | URL to thumbnail image |
22+
| string | art | |
23+
| array | genre | Genre's of music the artist has performed in |
24+
| array | country | Country's the albums were recorded in |
25+
26+
## Function List
27+
| Visibility | Function (parameters,...): return |
28+
| :------------ | :----------------------------------------------------------------------------------------------------------------------------------------- |
29+
| public | <strong>__construct()</strong>: <em>void</em><br /> |
30+
| public | <strong>__get(</strong><em>string</em> <strong>$var)</strong>: <em>mixed</em><br />Magic getter |
31+
| public | <strong>__set(</strong><em>string</em> <strong>\$var</strong>, <em>mixed</em> <strong>$val)</strong>: <em>void</em><br />Magic setter |
32+
| public | <strong>getChildren()</strong>: <em>ItemCollection:Album</em><br />Method to retrieve all albums written by this artist |
33+
| public | <strong>addAlbum(</strong><em>Album</em> <strong>$a)</strong>: <em>void</em> |
34+
| public static | <strong>fromLibrary(</strong><em>array</em> <strong>$library)</strong>: <em>Artist</em><br />Create a Artist from the Plex API call return |

docs/Documentation.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
### Main Class
44

5-
[PlexApi](PlexApi.md)<br />
5+
[PlexApi](PlexApi.md)
66

77
### Collection Classes
88

@@ -11,10 +11,16 @@
1111

1212
### Media Classes
1313

14-
[Movie](Movie.md)<br />
15-
[Show](Show.md)<br />
16-
[Season](Season.md)<br />
17-
[Episode](Episode.md)<br />
14+
- Movie
15+
- [Movie](Movie.md)<br />
16+
- TV
17+
- [Show](Show.md)<br />
18+
- [Season](Season.md)<br />
19+
- [Episode](Episode.md)<br />
20+
- Music
21+
- [Artist](Artist.md)<br />
22+
- [Album](Album.md)<br />
23+
- [Track](Track.md)<br />
1824

1925
### Utility Classes
2026

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

35+
### Dev Testing
36+
37+
[Tests](Tests.md)
38+
2939
<hr />
3040

3141
## PlexApi

docs/Filter.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Filter
22

3-
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.
3+
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.**
44

55
## Function List
66

77
| Visibility | Function (parameters,...): return |
8-
|:-----------|:---------|
8+
| :--------- | :-------------------------------- |
99
| 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> |
1010
| public | <strong>__toString()</strong>: <em>string</em><br />Convert the object to a string |
1111

docs/PlexApi.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22

33
## Function List
44

5-
| Visibility | Function (parameters,...): return |
6-
|:-----------|:---------|
7-
| 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> |
5+
| Visibility | Function (parameters,...): return |
6+
| :--------------- | :---------------- |
7+
| 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> |
88
| public | <strong>getBaseInfo()</strong> : <em>array\|bool</em><br /><em>Get Plex Server basic info</em> |
9+
| public | <strong>getAccount()</strong> : <em>array\|bool</em><br /><em>Get account info</em> |
910
| public | <strong>getLastCallStats()</strong> : <em>array</em><br /><em>Get last curl stats, for debugging purposes</em> |
1011
| public | <strong>getLibrarySections()</strong> : <em>array\|bool</em><br /><em>Get Library Sections ie Movies, TV Shows etc</em> |
1112
| 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> |
1213
| public | <strong>getMetadata(</strong><em>int</em> <strong>$item</strong>)</strong> : <em>array\|bool</em><br /><em>Get Metadata for an Item</em> |
14+
| 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> |
1315
| public | <strong>getOnDeck(</strong><em>bool</em> <strong>$returnCollection = `false`)</strong> : <em>array\|ItemCollection\|bool</em><br /><em>Get On Deck Info</em> |
1416
| public | <strong>getRecentlyAdded(</strong><em>bool</em> <strong>$returnCollection = `false`)</strong> : <em>array\|ItemCollection\|bool</em><br /><em>Get Recently Added</em> |
1517
| public | <strong>getServers()</strong> : <em>array\|bool</em><br /><em>Get Servers</em> |
@@ -31,4 +33,5 @@
3133
| 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> |
3234
| 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> |
3335
| protected static | <strong>xml2array(</strong><em>mixed</em> <strong>$xml</strong>)</strong> : <em>mixed</em><br /><em>xml2array</em> |
34-
| public static | <strong>array2Collection(</strong><em>array</em> <strong>$array)</strong>: <em>ItemCollection</em> |
36+
| public static | <strong>array2collection(</strong><em>array</em> <strong>$array)</strong>: <em>ItemCollection</em> |
37+
| public static | <strong>array2object(</strong><em>array</em> <strong>$array)</strong>: <em>Movie\|Show\|Season\|Episode\|Artist\|Album\|Track</em> |

docs/Season.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ This represents a single season within a show
2626
| int | viewedLeafCount | The number of times an episode in this season was viewed |
2727
| `DateTime` | addedAt | The date and time this season was added to the library |
2828
| `DateTime` | updatedAt | The date and time this season was last updated in the library |
29-
| array:[Episode](Episode.md) | episodes | An array to store all the episodes in this season |
29+
| `ItemCollection`:`Episode`(Episode.md) | episodes | An array to store all the episodes in this season |
3030

3131
## Function List
3232

@@ -35,6 +35,6 @@ This represents a single season within a show
3535
| public | <strong>__construct()</strong>: <em>void</em><br /> |
3636
| public | <strong>__get(</strong><em>string</em> <strong>$var)</strong>: <em>mixed</em><br />Magic getter |
3737
| public | <strong>__set(</strong><em>string</em> <strong>$var</strong>, <em>mixed</em> <strong>$val)</strong>: <em>void</em><br />Magic setter |
38-
| public | <strong>getEpisodes()</strong>: <em>array:Episodes</em><br />Method to get all episodes within this season |
38+
| public | <strong>getChildren()</strong>: <em>ItemCollection:Episodes</em><br />Method to get all episodes within this season |
3939
| public | <strong>addEpisode(</strong><em>Episode</em> <strong>$episode)</strong>: <em>void</em><br />Method to add an episode to the season |
4040
| public static | <strong>fromLibrary(</strong><em>array</em> <strong>$lib)</strong>: <em>Season</em><br />Method to create a season |

docs/Show.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ A TV Show
3434
| string | audienceRatingImage | |
3535
| array:string | genre | The genres the show is in |
3636
| array:string | role | The actor/actresses in the show |
37-
| array:[Season](Season.md) | seasons | The array containing all the seasons |
37+
| `ItemCollection`:`Season`(Season.md) | seasons | The array containing all the seasons |
3838

3939
## Function List
4040

@@ -43,6 +43,6 @@ A TV Show
4343
| public | <strong>__construct()</strong>: <em>void</em><br /> |
4444
| public | <strong>__get(</strong><em>string</em> <strong>$var)</strong>: <em>mixed</em><br />Magic getter |
4545
| public | <strong>__set(</strong><em>string</em> <strong>$var</strong>, <em>mixed</em> <strong>$val)</strong>: <em>void</em><br />Magic setter |
46-
| public | <strong>getSeasons()</strong>: <em>array:Season</em><br />Method to get the seasons |
46+
| public | <strong>getChildren()</strong>: <em>array:Season</em><br />Method to get the seasons |
4747
| public | <strong>addSeason(</strong><em>Season</em> <strong>$season)</strong>: <em>bool</em><br />Method to add a season to the show |
4848
| 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 |

docs/Tests.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Tests
2+
3+
## Intro
4+
5+
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:
6+
7+
| **Env** | **Value** | **Description** |
8+
| ---------------------- | -------------- | -------------------------------------------------------------------------- |
9+
| **PLEX_HOST** | *ip\|hostname* | IP or host name of the Plex server |
10+
| **PLEX_PORT** | *port* | Port to connect to Plex server (optional, defaults 32400) |
11+
| **PLEX_USER** | *email* | Username to login to Plex.tv (only needed once) |
12+
| **PLEX_PASSWORD** | *password* | Password to login to Plex.tv (only needed once) |
13+
| **PLEX_SSL** | *0\|1* | Boolean to connect to Plex server over SSL |
14+
| **MOVIE_TESTS** | *0\|1* | Boolean to conduct tests on movie library (optional) |
15+
| **MOVIE_SECTION_KEY** | *int* | Integer of movie library (run `composer sections` to see list |
16+
| **MOVIE_ITEM_ID** | *int* | Integer key of a specific movie to pull metadata for |
17+
| **MOVIE_SEARCH_QUERY** | *string* | String query to search for in Movie library |
18+
| **MOVIE_FILTER_QUERY** | *string* | String query to filter for in Movie library (must be a 'title') |
19+
| **TV_TESTS** | *0\|1* | Boolean to conduct tests of TV library (optional) |
20+
| **TV_SECTION_KEY** | *int* | Integer of TV library (run `composer sections` to see list) |
21+
| **TV_ITEM_ID** | *int* | Integer key of a specific TV show, season, or episode to pull metadata for |
22+
| **TV_SEARCH_QUERY** | *string* | String query to search for in TV library |
23+
| **TV_FILTER_QUERY** | *string* | String query to filter for in TV library (must be 'title') |
24+
| **MUSIC_TESTS** | *0\|1* | Boolean to conduct tests of Music library (optional) |
25+
| **MUSIC_SECTION_KEY** | *int* | Integer of Music library (run `composer sections` to see list |
26+
| **MUSIC_SEARCH_QUERY** | *string* | String query to search for in Music library |
27+
| **MUSIC_FILTER_QUERY** | *string* | String query to filter for in Music library |
28+
29+
The `PLEX_*` values are required. The username and password values can be deleted after the token is retrieved
30+
31+
`*_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.
32+
33+
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

0 commit comments

Comments
 (0)