Browse Source

initial commit

Romain Kerguelen 8 months ago
commit
74a0be3ee8
Signed by: Rigel Kent <sendmemail@rigelk.eu> GPG Key ID: EA12971B0E438F36
4 changed files with 545 additions and 0 deletions
  1. 2
    0
      .gitignore
  2. 60
    0
      api.py
  3. 461
    0
      poetry.lock
  4. 22
    0
      pyproject.toml

+ 2
- 0
.gitignore View File

@@ -0,0 +1,2 @@
1
+*.pyc
2
+__pycache__/

+ 60
- 0
api.py View File

@@ -0,0 +1,60 @@
1
+from __future__ import print_function
2
+from prismedia import upload import main as upload
3
+
4
+import sys
5
+import zerorpc
6
+
7
+
8
+class PrismediahedronAPI():
9
+    prismedia =
10
+
11
+    def upload(self, *args, **kwargs):
12
+        """upload video using prismedia"""
13
+        arguments = [
14
+                self.prismedia,
15
+                *args,
16
+                *kwargs
17
+                ]
18
+
19
+        try:
20
+            output = subprocess.check_output(
21
+                arguments,
22
+                stderr=subprocess.STDOUT)
23
+
24
+            return uploader._geturl(output)
25
+
26
+        except subprocess.CalledProcessError as cpe:
27
+            print "cpe.returncode", cpe.returncode
28
+            print "cpe.cmd", cpe.cmd
29
+            print "cpe.output", cpe.output
30
+
31
+    @staticmethod
32
+    def _geturl(s):
33
+        # the output contains much more than just the url
34
+        cue = "Peertube: Watch it at "
35
+        for line in s.split("\n"):
36
+            if cue in line:
37
+                # the url befins right after the cue. Between in url and the end of the line is a single ".",
38
+                # which also needs to be remove
39
+                return line.split(cue, 1)[1][:-1]
40
+
41
+
42
+def parse_port():
43
+    port = 4242
44
+    try:
45
+        port = int(sys.argv[1])
46
+    except Exception as e:
47
+        pass
48
+    return '{}'.format(port)
49
+
50
+
51
+def main():
52
+    addr = 'tcp://127.0.0.1:' + parse_port()
53
+    s = zerorpc.Server(PrismediahedronAPI())
54
+    s.bind(addr)
55
+    print('prismediahedron started on {}'.format(addr))
56
+    s.run()
57
+
58
+
59
+if __name__ == '__main__':
60
+    main()

+ 461
- 0
poetry.lock
File diff suppressed because it is too large
View File


+ 22
- 0
pyproject.toml View File

@@ -0,0 +1,22 @@
1
+[tool.poetry]
2
+name = "prismediahedron"
3
+version = "0.1.0"
4
+description = "a zerorpc server exposing prismedia, a video uploader to PeerTube and friends."
5
+authors = ["Rigel Kent <sendmemail@rigelk.eu>"]
6
+license = "AGPL-3.0-only"
7
+
8
+[tool.poetry.dependencies]
9
+python = "^3.4"
10
+pyinstaller = "^3.4"
11
+zerorpc = "^0.6.1"
12
+
13
+# prismedia
14
+prismedia = { path = "../prismedia/" }
15
+pyzmq = "^18.0"
16
+msgpack-python = "^0.5.6"
17
+
18
+[tool.poetry.dev-dependencies]
19
+
20
+[build-system]
21
+requires = ["poetry>=0.12"]
22
+build-backend = "poetry.masonry.api"

Loading…
Cancel
Save