59 |
60 |
--------------------------------------------------------------------------------
/php/basic-hls-stream-based.php:
--------------------------------------------------------------------------------
1 |
29 |
--------------------------------------------------------------------------------
/php/basic-rtsp.php:
--------------------------------------------------------------------------------
1 |
30 |
--------------------------------------------------------------------------------
/php/jwpayer-rtmp-hls-with-proxy.php:
--------------------------------------------------------------------------------
1 |
36 |
37 |
38 |
52 |
--------------------------------------------------------------------------------
/php/jwpayer-rtmp-hls.php:
--------------------------------------------------------------------------------
1 |
19 |
20 |
21 |
35 |
--------------------------------------------------------------------------------
/php/ppv-rtsp-rtmp.php:
--------------------------------------------------------------------------------
1 |
2 |
25 |
26 |
27 |
28 |
29 |
30 | RTMP publish signature: =$rtmp_url?>
31 | RTSP publish signature: =$rtsp_url?>
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/php/rtmp-flowplayer.php:
--------------------------------------------------------------------------------
1 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
48 |
49 |
50 |
51 |
52 |
57 |
58 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/python/ppv_media_signature.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # coding: utf8
3 |
4 | import base64
5 | from hashlib import md5
6 | from time import gmtime, strftime
7 |
8 |
9 | def ppv_url_with_signature(ip, user_id, password, validminutes, initial_url, signed_stream="", strm_len=0):
10 | """
11 | Get URL with signature when using PayPerView method with Nimble
12 | :param ip: Viewer IP address
13 | :param user_id: User ID used in back-end web server
14 | :param password: hot-link protection password configured in WMSPanel Auth Rule
15 | :param validminutes: Valid duration of the URL in minutes. After this time, the URL will not work
16 | :param initial_url: Full URL stream you want to protect
17 | :param signed_stream: stream name to make it unique for each stream
18 | https://blog.wmspanel.com/2014/10/stream-name-hotlink-protection.html
19 | You may also use part of the name if you need to protect streams by pattern !
20 | :param strm_len: len(signed_stream)
21 | :return: Signed URL
22 | """
23 | today = strftime("%m/%d/%Y %I:%M:%S %p", gmtime())
24 | key = (ip + user_id + password + today + validminutes + signed_stream).encode()
25 | m = md5(key)
26 | base64hash = base64.b64encode(m.digest())
27 | urlsignature = ("server_time=" + today + "&hash_value=" + base64hash.decode('utf-8') + "&validminutes=" +
28 | validminutes + "&strm_len=" + str(strm_len) + "&id=" + user_id + "&checkip=true").encode()
29 | base64urlsignature = base64.b64encode(urlsignature)
30 | signedurlwithvalidinterval = initial_url + "?wmsAuthSign=" + base64urlsignature.decode('utf-8')
31 | return signedurlwithvalidinterval
32 |
33 |
34 | def verify_ppv_signature(ppv_sync, token):
35 | """
36 | @param ppv_sync: ppv sync JSON sent by wmspanel
37 | @param token: Secret Token configured into WMS Panel push API
38 | @return: True if calculated signature == sent signature. Else, return False
39 | """
40 | try:
41 | sync_id = ppv_sync["ID"]
42 | puzzle = ppv_sync["Puzzle"]
43 | signature = ppv_sync["Signature"]
44 | except KeyError as error:
45 | raise KeyError(error)
46 | key = (sync_id + puzzle + token).encode()
47 | m = md5(key)
48 | base64hash = base64.b64encode(m.digest()).decode()
49 | if signature == base64hash:
50 | return True
51 | else:
52 | return False
53 |
54 |
55 | def generate_ppv_solution(puzzle, token):
56 | """
57 | @param puzzle: 'Puzzle' value in JSON that is sent by nimble POST request
58 | @param token: Secret Token configured into WMS Panel push API
59 | @return: signature solution (string)
60 | """
61 | key = (puzzle + token).encode()
62 | m = md5(key)
63 | base64hash = base64.b64encode(m.digest()).decode()
64 | return base64hash
65 |
--------------------------------------------------------------------------------
/python/wmsauth.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # coding: utf8
3 |
4 | import base64
5 | from hashlib import md5
6 | from time import gmtime, strftime
7 |
8 |
9 | def get_media_url_with_signature(ip, password, validminutes, initial_url, signed_stream="", strm_len=0):
10 | """
11 | Get URL with Hot-link protection signature
12 | :param ip: Viewer IP address
13 | :param password: hot-link protection password wonfigured in WMSPanel Auth Rule
14 | :param validminutes: Valid duration of the URL in minutes. After this time, the URL will not work
15 | :param initial_url: Full URL stream you want to protect
16 | :param signed_stream: stream name to make it unique for each stream
17 | https://blog.wmspanel.com/2014/10/stream-name-hotlink-protection.html
18 | You may also use part of the name if you need to protect streams by pattern !
19 | :param strm_len: len(signed_stream)
20 | :return: Signed URL
21 | """
22 | today = strftime("%m/%d/%Y %I:%M:%S %p", gmtime())
23 | key = (ip + password + today + validminutes + signed_stream).encode()
24 | m = md5(key)
25 | base64hash = base64.b64encode(m.digest())
26 | urlsignature = ("server_time=" + today + "&hash_value=" + base64hash.decode('utf-8') + "&validminutes=" +
27 | validminutes + "&strm_len=" + str(strm_len)).encode()
28 | base64urlsignature = base64.b64encode(urlsignature)
29 | signedurlwithvalidinterval = initial_url + "?wmsAuthSign=" + base64urlsignature.decode('utf-8')
30 | return signedurlwithvalidinterval
31 |
32 |
--------------------------------------------------------------------------------