-
Notifications
You must be signed in to change notification settings - Fork 14
/
emplexer_root_list.php
executable file
·122 lines (99 loc) · 3.7 KB
/
emplexer_root_list.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php
/**
*
*/
class EmplexerRootList extends AbstractPreloadedRegularScreen
{
const ID = "plex_root_list";
function __construct()
{
// hd_print(__METHOD__);
parent::__construct(self::ID, $this->get_folder_views());
}
public static function get_media_url_str($category_id, $filter_name=null,$type='show')
{
// hd_print(__METHOD__);
// hd_print(' category_id: ' . $category_id . ' filter_name: ' . $filter_name);
$filter_name = !isset($filter_name)?'all':$filter_name;
return MediaURL::encode(
array
(
'screen_id' => self::ID,
'category_id' => $category_id,
'filter_name' => $filter_name,
'type' => $type
)
);
}
public function get_action_map(MediaURL $media_url, &$plugin_cookies)
{
// hd_print(__METHOD__);
$enter_action = ActionFactory::open_folder();
return array
(
GUI_EVENT_KEY_ENTER => $enter_action,
GUI_EVENT_KEY_PLAY => $enter_action,
);
}
public function get_all_folder_items(MediaURL $media_url , &$plugin_cookies){
// hd_print(__METHOD__);
//hd_print(__METHOD__ . ':' . print_r($media_url, true));
$doc = HD::http_get_document(
EmplexerConfig::getInstance()->getPlexBaseUrl($plugin_cookies, $this) .
'/library/sections/' .
$media_url->category_id .
'/' . $media_url->filter_name
);
$xml = simplexml_load_string($doc);
$items = array();
$cache_keys = array();
foreach ($xml->Directory as $c)
{
$thumb =(string)$c->attributes()->thumb;
$url = EmplexerConfig::getInstance()->getPlexBaseUrl($plugin_cookies, $this) . '/photo/:/transcode?width='.THUMB_WIDTH. '&height='. THUMB_HEIGHT . '&url=' . EmplexerConfig::getInstance()->getPlexBaseUrl($plugin_cookies, $this). $thumb;
// $urlb = EmplexerConfig::getInstance()->getPlexBaseUrl($plugin_cookies, $this) . (string)$c->attributes()->thumb;
// hd_print(__METHOD__ . ':EmplexerConfig::getInstance()->useCache= ' . EmplexerConfig::getInstance()->useCache . ' tipo = ' . gettype(EmplexerConfig::getInstance()->useCache));
// if (EmplexerConfig::getInstance()->useCache === 'false'){
// hd_print('Entrou.... ' );
// $url = EmplexerConfig::getInstance()->getPlexBaseUrl($plugin_cookies, $this). $thumb;
// }
$bgImage = EmplexerConfig::getInstance()->getPlexBaseUrl($plugin_cookies, $this) . $c->attributes()->art;
$caption = (string) $c->attributes()->ratingKey . '.jpg';
if ($thumb){
EmplexerArchive::getInstance()->setFileToArchive($caption, $url );
}
$items[] = array
(
PluginRegularFolderItem::media_url => $this->get_right_media_url($media_url,$c),
PluginRegularFolderItem::caption => (string) $c->attributes()->title,
PluginRegularFolderItem::view_item_params =>
array
(
ViewItemParams::icon_path => EmplexerArchive::getInstance()->getFileFromArchive($caption, $url),
ViewItemParams::item_detailed_icon_path => EmplexerArchive::getInstance()->getFileFromArchive($caption, $url),
ViewItemParams::icon_keep_aspect_ratio => false
)
);
}
// hd_print(__METHOD__ .':'. print_r($items, true));
return $items;
}
private function get_right_media_url(MediaURL $media_url, $node)
{
// hd_print(__METHOD__);
$episodes = array( 'newest' , 'recentlyAdded', 'recentlyViewed', 'onDeck');
$season = array('all','recentlyViewedShows');
if (in_array($media_url->filter_name , $episodes)){
return EmplexerVideoList::get_media_url_str((string)$node->attributes()->key);
} else {
return EmplexerSeasonList::get_media_url_str((string)$node->attributes()->key);
}
}
public function get_folder_views()
{
// hd_print(__METHOD__);p
// return EmplexerConfig::getInstance()->GET_SECTIONS_LIST_VIEW();
return EmplexerConfig::getInstance()->GET_VIDEOS_LIST_VIEW();
}
}
?>