Skip to content

Commit

Permalink
revert to 1.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Wizmo2 committed Dec 9, 2021
1 parent 05a705b commit a6dcbeb
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 79 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ Release 1.1 is tested from HA versions 2021.1 up to 2021.10, and requires manual

## Installation

### HACS Install
### HACS Install

NOTE: HACS/default PR is awaiting review. Until then you would have to add the https://github.com/wizmo2/zidoo-player as a custom repository or use the manual method.

1. Search for `Zidoo` under `Integrations` in the HACS Store tab.
2. **You will need to restart after installation for the component to start working.**
3. Configure the integation (see Configuration section)

### Manual Install

1. Copy `zidoo` folder to `\config\custom_components` (create folder if this is yuor first custom integration)
1. Copy `zidoo` folder from zidoo-player/custom_components to `\config\custom_components` (create folder if this is your first custom integration)
2. Restart HA

### Configuration
Expand Down
2 changes: 1 addition & 1 deletion custom_components/zidoo/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"requirements": [],
"codeowners": ["@wizmo2"],
"iot_class": "local_polling",
"version": "1.2.2"
"version": "1.2.3"
}
119 changes: 64 additions & 55 deletions custom_components/zidoo/media_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,37 @@
MEDIA_CLASS_SEASON,
MEDIA_CLASS_TV_SHOW,
MEDIA_CLASS_VIDEO,
MEDIA_TYPE_MUSIC,
MEDIA_TYPE_ALBUM,
MEDIA_TYPE_ARTIST,
MEDIA_TYPE_GENRE,
MEDIA_TYPE_PLAYLIST,
MEDIA_TYPE_TRACK,
MEDIA_TYPE_SEASON,
MEDIA_TYPE_MOVIE,
MEDIA_TYPE_TVSHOW,
MEDIA_TYPE_EPISODE,
MEDIA_TYPE_VIDEO,
MEDIA_TYPE_URL,
)

BROWSE_LIMIT = 1000
MEDIA_TYPE_FILE = "file"

ITEM_TYPE_MEDIA_CLASS = {
"album": MEDIA_CLASS_ALBUM,
"artist": MEDIA_CLASS_ARTIST,
"episode": MEDIA_CLASS_EPISODE,
"movie": MEDIA_CLASS_MOVIE,
"playlist": MEDIA_CLASS_PLAYLIST,
"season": MEDIA_CLASS_SEASON,
"show": MEDIA_CLASS_TV_SHOW,
"track": MEDIA_CLASS_TRACK,
"video": MEDIA_CLASS_VIDEO,
"file": MEDIA_CLASS_DIRECTORY,
MEDIA_TYPE_ALBUM: MEDIA_CLASS_ALBUM,
MEDIA_TYPE_ARTIST: MEDIA_CLASS_ARTIST,
MEDIA_TYPE_EPISODE: MEDIA_CLASS_EPISODE,
MEDIA_TYPE_MOVIE: MEDIA_CLASS_MOVIE,
MEDIA_TYPE_PLAYLIST: MEDIA_CLASS_PLAYLIST,
MEDIA_TYPE_SEASON: MEDIA_CLASS_SEASON,
MEDIA_TYPE_TVSHOW: MEDIA_CLASS_TV_SHOW,
MEDIA_TYPE_TRACK: MEDIA_CLASS_TRACK,
MEDIA_TYPE_VIDEO: MEDIA_CLASS_VIDEO,
MEDIA_TYPE_FILE: MEDIA_CLASS_DIRECTORY,
}

MOVIE_TYPE_MEDIA_CLASS = {
ZMOVIE_TYPE_MEDIA_CLASS = {
0: MEDIA_CLASS_VIDEO,
1: MEDIA_CLASS_MOVIE,
2: MEDIA_CLASS_TRACK,
Expand All @@ -47,27 +53,35 @@
7: MEDIA_CLASS_TRACK,
}

CONTENT_ITEM_TYPE = {
0: "file",
1: "track",
2: "video",
ZCONTENT_ITEM_TYPE = {
0: MEDIA_TYPE_FILE, # folder
1: MEDIA_TYPE_TRACK, # music
2: MEDIA_TYPE_VIDEO, # video
# 3: 'image', # 4: 'text', # 5: 'apk', # 6: 'pdf', # 7: 'document', # 8: 'spreadsheet', # 9: 'presentation', # 10: 'web', # 11: 'archive' , # 12: 'other'
1000: "file", # hhd
1001: "file", # usb
1002: "file", # usb
1003: "file", # tf
1004: "file", # nfs
1005: "file", # smb
1006: "file",
1007: "file",
1008: "file",
1000: MEDIA_TYPE_FILE, # hhd
1001: MEDIA_TYPE_FILE, # usb
1002: MEDIA_TYPE_FILE, # usb
1003: MEDIA_TYPE_FILE, # tf
1004: MEDIA_TYPE_FILE, # nfs
1005: MEDIA_TYPE_FILE, # smb
1006: MEDIA_TYPE_FILE,
1007: MEDIA_TYPE_FILE,
1008: MEDIA_TYPE_FILE,
}

FAVORITES = [
# {"name": "DOWNLOADS", "path": "/tmp/ramfs/mnt/192.168.1.1%23SHARED/DOWNLOAD"},
# {"name": "AUDIO", "path": "/tmp/ramfs/mnt/192.168.1.1%23SHARED/AUDIO"},
]
ZITEM_TYPE_FILTER = {
MEDIA_TYPE_FILE: 0,
MEDIA_TYPE_MOVIE: 3,
MEDIA_TYPE_TVSHOW: 4,
}

ZTITLE = "Zidoo Media"

ZFAVORITES = [
{"name": "DOWNLOADS", "path": "/tmp/ramfs/mnt/192.168.1.1%23SHARED/DOWNLOAD", "type": MEDIA_TYPE_FILE},
{"name": "MOVIES", "path": MEDIA_TYPE_MOVIE, "type": MEDIA_TYPE_MOVIE},
{"name": "TV SHOW", "path": MEDIA_TYPE_TVSHOW, "type": MEDIA_TYPE_TVSHOW}
]

def browse_media( # noqa: C901
entity, is_internal, media_content_type=None, media_content_id=None
Expand All @@ -83,6 +97,7 @@ def build_item_response(player, payload):
media_class = ITEM_TYPE_MEDIA_CLASS[search_type]
child_media_class = MEDIA_CLASS_DIRECTORY
children = None
title = ZTITLE

if media_class == MEDIA_CLASS_DIRECTORY:
result = player.get_file_list(search_id)
Expand All @@ -93,8 +108,8 @@ def build_item_response(player, payload):
for item in result["filelist"]:
content_type = item["type"]
item_type = None
if content_type is not None and content_type in CONTENT_ITEM_TYPE:
item_type = CONTENT_ITEM_TYPE[content_type]
if content_type is not None and content_type in ZCONTENT_ITEM_TYPE:
item_type = ZCONTENT_ITEM_TYPE[content_type]
if item_type is not None:
child_media_class = ITEM_TYPE_MEDIA_CLASS[item_type]
item_thumbnail = None
Expand All @@ -111,42 +126,48 @@ def build_item_response(player, payload):
)
)

if media_class == MEDIA_CLASS_MOVIE:
if media_class == MEDIA_CLASS_MOVIE or media_class == MEDIA_CLASS_TV_SHOW:
result = None
if search_id == MEDIA_TYPE_MOVIE:
result = player.get_movie_list()
title = "MOVIES"
result = player.get_movie_list(1000, ZITEM_TYPE_FILTER[search_id])
elif search_id == MEDIA_TYPE_TVSHOW:
title = "TV SHOW"
result = player.get_movie_list(1000, ZITEM_TYPE_FILTER[search_id])
else:
result = player.get_collection_list(search_id)

if result is not None and result.get("data"):
child_media_class = MEDIA_CLASS_MOVIE
if result.get("type"):
child_media_class = MOVIE_TYPE_MEDIA_CLASS[result["type"] + 1]
child_media_class = ZMOVIE_TYPE_MEDIA_CLASS[result["type"] + 1]
children = []
for item in result["data"]:
child_type = item["type"]
item_id = item["id"]
item_type = MEDIA_TYPE_MOVIE
item_type = search_type
# item_thumbnail = None
item_thumbnail = entity.get_browse_image_url(item_type, item_id)

children.append(
BrowseMedia(
title=item["name"],
media_class=MEDIA_CLASS_MOVIE,
media_class=media_class,
media_content_id=str(item_id),
media_content_type=item_type,
can_play=child_type in {1, 5, 6},
can_expand=child_type in {3, 4},
can_expand=child_type in {2, 3, 4},
thumbnail=item_thumbnail,
)
)
if result.get("name"):
title = result.get("name")

if children is None:
raise BrowseError(f"Media not found: {search_type} / {search_id}")

return BrowseMedia(
title="Zidoo Media",
title=title,
media_class=media_class,
children_media_class=child_media_class,
media_content_id=search_id,
Expand All @@ -169,39 +190,27 @@ def library_payload(player):
}

# Add favorite
for item in FAVORITES:
for item in ZFAVORITES:
library_info["children"].append(
BrowseMedia(
title=item["name"],
media_class=MEDIA_CLASS_DIRECTORY,
media_class=ITEM_TYPE_MEDIA_CLASS[item["type"]],
media_content_id=item["path"],
media_content_type="file",
media_content_type=item["type"],
can_play=False,
can_expand=True,
)
)

# Add Movies
library_info["children"].append(
BrowseMedia(
title="MOVIES",
media_class=MEDIA_CLASS_MOVIE,
media_content_id=MEDIA_TYPE_MOVIE,
media_content_type=MEDIA_TYPE_MOVIE,
can_play=False,
can_expand=True,
)
)

result = player.get_device_list()

if result is not None and result.get("devices"):

for item in result["devices"]:
content_type = item["type"]
item_type = None
if content_type is not None and content_type in CONTENT_ITEM_TYPE:
item_type = CONTENT_ITEM_TYPE[content_type]
if content_type is not None and content_type in ZCONTENT_ITEM_TYPE:
item_type = ZCONTENT_ITEM_TYPE[content_type]
if item_type is not None:
child_media_class = ITEM_TYPE_MEDIA_CLASS[item_type]
item_thumbnail = None
Expand All @@ -213,7 +222,7 @@ def library_payload(player):
media_content_id=item["path"],
media_content_type=item_type,
can_play=False,
can_expand=child_media_class == MEDIA_CLASS_DIRECTORY,
can_expand=(child_media_class==MEDIA_CLASS_DIRECTORY),
thumbnail=item_thumbnail,
)
)
Expand Down
14 changes: 5 additions & 9 deletions custom_components/zidoo/media_player.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Support for interface with Zidoo Media Player."""
import logging

from .zidoorc import ZidooRC
from .zidoorc import ZidooRC, ZCONTENT_MUSIC, ZCONTENT_VIDEO
import voluptuous as vol

from homeassistant.components.media_player import PLATFORM_SCHEMA, MediaPlayerEntity
Expand Down Expand Up @@ -69,10 +69,6 @@
}
)

ZIDOO_VIDEOPLAYER = "Media Center"
ZIDOO_ZIDOOPOSTER = "Home Theater 3.0"
ZIDOO_MUSICPLAYER = "Music Player 5.0"

SUPPORT_ZIDOO = (
SUPPORT_VOLUME_STEP
| SUPPORT_VOLUME_MUTE
Expand Down Expand Up @@ -182,10 +178,10 @@ def update(self):
if mediatype and mediatype is not None:
if mediatype == "video":
self._program_media_type = MEDIA_TYPE_VIDEO
self._source = ZIDOO_VIDEOPLAYER
self._source = ZCONTENT_VIDEO
else:
self._program_media_type = MEDIA_TYPE_MUSIC
self._source = ZIDOO_MUSICPLAYER
self._source = ZCONTENT_MUSIC
else:
self._program_media_type = MEDIA_TYPE_APP
status = playing_info.get("status")
Expand Down Expand Up @@ -232,7 +228,7 @@ def _refresh_volume(self):
def _refresh_channels(self):
if not self._source_list:
self._content_mapping = self._player.load_source_list()
self._source_list = []
self._source_list = [ ZCONTENT_VIDEO, ZCONTENT_MUSIC ]
for key in self._content_mapping:
self._source_list.append(key)

Expand Down Expand Up @@ -374,7 +370,7 @@ def media_previous_track(self):

def play_media(self, media_type, media_id, **kwargs):
"""Play a piece of media."""
if media_type and media_type == "movie":
if media_type and (media_type == "movie" or media_type == 'tvshow'):
self._player.play_movie(media_id)
else:
self._player.play_content(media_id)
Expand Down
Loading

0 comments on commit a6dcbeb

Please sign in to comment.