Skip to content

Commit

Permalink
Release v2.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
hyugogirubato committed Jun 7, 2023
1 parent 1603899 commit 54dc9a1
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 11 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.1.5] - 2023-06-07

### Fixed

- Identification of DRM systems using the same key.
- Creation of the profile with `Representation` and/or `AdaptationSet`.
- Correction of the dynamic value `#EXT-X-TARGETDURATION`.

### Changed

- `startWithSAP` transformed into a boolean.

## [2.1.4] - 2023-06-06

### Added
Expand Down Expand Up @@ -88,6 +100,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

- Initial release.

[2.1.5]: https://github.com/hyugogirubato/pydash2hls/releases/tag/v2.1.5
[2.1.4]: https://github.com/hyugogirubato/pydash2hls/releases/tag/v2.1.4
[2.1.3]: https://github.com/hyugogirubato/pydash2hls/releases/tag/v2.1.3
[2.1.2]: https://github.com/hyugogirubato/pydash2hls/releases/tag/v2.1.2
Expand Down
2 changes: 1 addition & 1 deletion pydash2hls/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .converter import Converter

__version__ = "2.1.4"
__version__ = "2.1.5"
23 changes: 16 additions & 7 deletions pydash2hls/converter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from __future__ import annotations

import base64
import re
from collections import Counter
from pathlib import Path
from typing import Optional

Expand All @@ -22,8 +24,15 @@ def _get_drm(adaptation: dict) -> dict:

for key, value in keys.items():
if value in protection:
scheme_id = re.sub(r'[^0-9a-f]', "", protection.get("@schemeIdUri", "").replace("urn:uuid:", "").lower())
if scheme_id == "edef8ba979d64acea3c827dcd51d21ed":
key = "widevine"
elif scheme_id == "9a04f07998404286ab92e65be0885f95":
key = "playready"

item = protection[value]
drm[key] = item if isinstance(item, str) else item["#text"]
item = item if isinstance(item, str) else item["#text"]
drm[key] = item.lower() if key == "kid" else item
return drm


Expand Down Expand Up @@ -90,15 +99,15 @@ def _manifest_profiles(self) -> None:

for representation in representations:
mime_type = self._get_key(adaptation, representation, "@mimeType") or ("video/mp4" if "avc" in representation["@codecs"] else "audio/m4a")
start_with_sap = self._get_key(adaptation, representation, "@startWithSAP") or "1"
start_with_sap = (self._get_key(adaptation, representation, "@startWithSAP") or "1") == "1"
if "video" not in mime_type and "audio" not in mime_type:
continue

profile = {
"id": representation["@id"],
"id": representation.get("@id") or adaptation.get("@id"),
"mimeType": mime_type,
"codecs": representation["@codecs"],
"bandwidth": int(representation["@bandwidth"]),
"codecs": representation.get("@codecs") or adaptation.get("@codecs"),
"bandwidth": int(representation.get("@bandwidth") or adaptation.get("@bandwidth")),
"startWithSAP": start_with_sap
}
if "audio" in profile["mimeType"] or "@audioSamplingRate" in representation:
Expand Down Expand Up @@ -210,12 +219,12 @@ def _manifest_profiles(self) -> None:
def build_hls(self, profile_id: str, licence: str = None) -> str:
profile = self._get_profile(profile_id)
sequence = 0 if len(profile["fragments"]) == 1 else 1
duration = int(max([float(f["extinf"]) for f in profile["fragments"]]))
duration, _ = Counter([float(f["extinf"]) for f in profile["fragments"]]).most_common(1)[0]
hls = [
"#EXTM3U",
"#EXT-X-VERSION:6",
f"#EXT-X-MEDIA-SEQUENCE:{sequence}",
f"#EXT-X-TARGETDURATION:{duration}",
f"#EXT-X-TARGETDURATION:{int(duration)}",
"#EXT-X-PLAYLIST-TYPE:VOD",
"#EXT-X-ALLOW-CACHE:YES",
]
Expand Down
14 changes: 11 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="pydash2hls",
version="2.1.4",
version="2.1.5",
author="hyugogirubato",
author_email="hyugogirubato@gmail.com",
description="Python library for converting DASH manifest files to HLS format.",
Expand All @@ -11,7 +11,12 @@
url="https://github.com/hyugogirubato/pydash2hls",
packages=find_packages(),
license="GPL-3.0-only",
keywords=["manifest", "hls", "m3u8", "dash"],
keywords=[
"manifest",
"hls",
"m3u8",
"dash"
],
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
Expand All @@ -25,6 +30,9 @@
"Programming Language :: Python :: 3.10",
"Topic :: Utilities"
],
install_requires=["requests", "xmltodict"],
install_requires=[
"requests",
"xmltodict"
],
python_requires=">=3.7"
)

0 comments on commit 54dc9a1

Please sign in to comment.