main.py
import datetime
import os
from cf_secure_edge import cf_token
def get_timedelta(str_val = ''):
if str_val.endswith("m"):
return datetime.timedelta(minutes=int(str_val[0:-1]))
if str_val.endswith("h"):
return datetime.timedelta(hours=int(str_val[0:-1]))
if str_val.endswith("d"):
return datetime.timedelta(days=int(str_val[0:-1]))
return int(str_val)
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
url = os.environ["URL"]
key = os.environ["KEY"]
key_id = os.environ["KEY_ID"]
exp = os.environ.get("EXP", "24h")
firstExp = os.environ.get("FIRST_EXP", "5m")
country = os.environ.get("CO", "")
region = os.environ.get("REG", "")
no_session = os.environ.get("NO_SSN", False)
user_agent = os.environ.get("UA", "")
referer = os.environ.get("REF", "")
token_policy = cf_token.TokenPolicy()
token_policy.expiry = get_timedelta(exp)
token_policy.first_access_expiry = get_timedelta(firstExp)
token_policy.session = not no_session
token_policy.country = len(country) > 0
token_policy.region = len(region) > 0
token_policy.headers = []
if len(user_agent) > 0:
token_policy.headers.append("user-agent")
if len(referer) > 0:
token_policy.headers.append("referer")
viewer_attrs = cf_token.ViewerAttributes()
viewer_attrs.country = country
viewer_attrs.region = region
viewer_attrs.headers = {
"user-agent": user_agent,
"referer": referer,
}
cf_token = cf_token.CfToken(secrets={key_id: key})
url_with_token = cf_token.generate_url(url, key_id, token_policy, viewer_attrs)
print(url_with_token)
URL=https://your-media-endpoint.com/master.m3u8 \
KEY_ID=your-key-id KEY=your-key \
UA="your-user-agent" \
REF=your-referrer \
python3 main.py
Metadata
Release files for cf-secure-edge 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cf_secure_edge-0.0.1.tar.gz | 2.9 kB | Without provenance | Details for cf_secure_edge-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cf_secure_edge-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for cf_secure_edge-0.0.1-py3-none-any.whl |
Total release size: 6.1 kB
Release files / cf_secure_edge-0.0.1.tar.gz
| Download URL | cf_secure_edge-0.0.1.tar.gz |
|---|---|
| Size | 2.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a8668220e266dc98eec718ee44300fe963db4d1c34c55c9ba79c98249cabfd27
|
|
BLAKE2b-256 checksum How to use checksums |
bf9842b761fdd14b1f054cc1af8c3dc1b95887e935bf3506b345b46ab3d7683e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.10
|
Release files / cf_secure_edge-0.0.1-py3-none-any.whl
| Download URL | cf_secure_edge-0.0.1-py3-none-any.whl |
|---|---|
| Size | 3.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b5436845443853c9e38d89b340d18d81b94368a931101cbbaf4237f36719de2c
|
|
BLAKE2b-256 checksum How to use checksums |
8a25e8d46fe64c875d1a5972ee9e4de48c5cdba0dceb88a22d3912000b8b7656
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.10
|
Security for cf-secure-edge 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.