MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/xstudio / inject_main

Function inject_main

python/src/xstudio/cli/inject.py:13–92  ·  view source on GitHub ↗

Do main function.

()

Source from the content-addressed store, hash-verified

11__version__ = xstudio.__version__
12
13def inject_main():
14 """Do main function."""
15 retval = 0
16 parser = argparse.ArgumentParser(
17 description=__doc__ + " Injects media into xStudio.",
18 formatter_class=argparse.ArgumentDefaultsHelpFormatter
19 )
20
21 parser.add_argument(
22 "-s", "--session", action="store",
23 type=str,
24 help="Host name.",
25 default=None
26 )
27
28 parser.add_argument(
29 "-H", "--host", action="store",
30 type=str,
31 help="Host name.",
32 default=None
33 )
34
35 parser.add_argument(
36 "-p", "--port", action="store",
37 type=int,
38 help="Port.",
39 default=14441
40 )
41
42 parser.add_argument(
43 "media", type=str, nargs="*", default=[],
44 help="Media paths to add."
45 )
46
47 args = parser.parse_args()
48
49 if args.session:
50 m = RemoteSessionManager(remote_session_path())
51 s = m.find(args.session)
52 conn = Connection()
53 conn.connect_remote(s.host(), s.port.port())
54
55 elif args.host:
56 conn = Connection()
57 conn.connect_remote(args.host, args.port)
58 else:
59 conn = Connection()
60 conn.connect_remote("localhost", args.port)
61
62 pl = conn.api.app.session.create_playlist("Injected Media")[1]
63
64 if len(args.media):
65 for path in args.media:
66 try:
67 path = os.path.abspath(path)
68 print("Added "+str(len(pl.add_media_list(path, True)))+" Media items.")
69 except ValueError as err:
70 print(str(err))

Callers

nothing calls this directly

Calls 12

findMethod · 0.95
connect_remoteMethod · 0.95
disconnectMethod · 0.95
ConnectionClass · 0.90
remote_session_pathFunction · 0.85
parse_argsMethod · 0.80
add_media_listMethod · 0.80
exitMethod · 0.80
hostMethod · 0.45
portMethod · 0.45
create_playlistMethod · 0.45

Tested by

no test coverage detected