├── .gitignore ├── README.md └── load.py /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.bak 3 | *.pyc 4 | *.pyo 5 | *.zip 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Live streaming software plugin for [EDMC](https://github.com/Marginal/EDMarketConnector/wiki) 2 | 3 | This plugin outputs status info from the game [Elite Dangerous](https://www.elitedangerous.com/) to files for use as [text sources](https://obsproject.com/wiki/Sources-Guide#text-gdi) in live streaming software such as [Open Broadcaster Software](https://obsproject.com/), [GameShow](http://gameshow.net/), [XSplit](https://www.xsplit.com/), etc. 4 | 5 | ## Installation 6 | 7 | * On EDMC's Plugins settings tab press the “Open” button. This reveals the `plugins` folder where EDMC looks for plugins. 8 | * Download the [latest release](https://github.com/Marginal/StreamSource/releases/latest). 9 | * Open the `.zip` archive that you downloaded and move the `StreamSource` folder contained inside into the `plugins` folder. 10 | 11 | You will need to re-start EDMC for it to notice the new plugin. 12 | 13 | ## Output 14 | 15 | The plugin writes the following status files into the folder that you specify in EDMC's Output settings tab: 16 | 17 | * `EDMC System.txt` - Name or the current star system. 18 | * `EDMC StarPos.txt` - Star system's galactic coordinates. 19 | * `EDMC Station.txt` - Name of the planetary or space station at which the player is docked. Empty if not docked. 20 | * `EDMC Body.txt` - Name of the nearby star, planet or ring. Empty if not near any celestial body. 21 | * `EDMC LatLon.txt` - Latitude and longitude coordinates. Empty if not near a planet. 22 | * `EDMC Station or Body.txt` - Name of the station if docked, otherwise the name of the nearby celestial body, or empty. 23 | * `EDMC Station or Body or System.txt` - Name of the station if docked, otherwise the name of the nearby celestial body, otherwise the name of the star system. 24 | * `EDMC ShipType.txt` - Ship type, e.g. Krait Phantom. 25 | * `EDMC ShipName.txt` - Ship name, if the ship has been named. Otherwise ship type. 26 | 27 | If the app is started while the game is not running these files hold placeholder values, which can be used to position the text in OBS Studio and other streaming software. 28 | 29 | ## License 30 | 31 | Copyright © 2019 Jonathan Harris. 32 | 33 | Licensed under the [GNU Public License (GPL)](http://www.gnu.org/licenses/gpl-2.0.html) version 2 or later. 34 | -------------------------------------------------------------------------------- /load.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Output status info to text files for use with streaming software such as Open Broadcaster Software, GameShow, XSplit, etc. 4 | # https://obsproject.com/wiki/Sources-Guide#text-gdi 5 | # https://telestream.force.com/kb2/articles/Knowledge_Article/Gameshow-Add-Text 6 | # https://www.xsplit.com/broadcaster/getting-started/adding-text 7 | # 8 | 9 | from io import open # For Python 2&3 a version of open that supports both encoding and universal newlines 10 | from os.path import join 11 | import sys 12 | 13 | from config import config 14 | from companion import ship_map 15 | from l10n import Locale 16 | 17 | VERSION = '1.10' 18 | 19 | this = sys.modules[__name__] # For holding module globals 20 | this.outdir = config.get('outdir') 21 | 22 | # Info recorded, with initial placeholder values 23 | this.system = 'System' 24 | this.station = 'Station' 25 | this.starpos = (0,0,0) 26 | this.body = 'Body' 27 | this.latlon = (0,0) 28 | this.stationorbody = 'Station or Body' 29 | this.stationorbodyorsystem = 'Station or Body or System' 30 | this.shiptype = 'Ship type' 31 | this.shipname = 'Ship name' 32 | 33 | 34 | # write out all files 35 | def write_all(): 36 | write_file('EDMC System.txt', this.system) 37 | write_file('EDMC StarPos.txt', '%s %s %s' % ( 38 | Locale.stringFromNumber(this.starpos[0], 5), 39 | Locale.stringFromNumber(this.starpos[1], 5), 40 | Locale.stringFromNumber(this.starpos[2], 5))) 41 | write_file('EDMC Station.txt', this.station) 42 | write_file('EDMC Body.txt', this.body) 43 | write_file('EDMC LatLon.txt', '%s %s' % ( 44 | Locale.stringFromNumber(this.latlon[0], 6), 45 | Locale.stringFromNumber(this.latlon[1], 6))) 46 | write_file('EDMC Station or Body.txt', this.stationorbody) 47 | write_file('EDMC Station or Body or System.txt', this.stationorbodyorsystem) 48 | write_file('EDMC ShipType.txt', this.shiptype) 49 | write_file('EDMC ShipName.txt', this.shipname) 50 | 51 | 52 | # write one file 53 | def write_file(name, text=None): 54 | # File needs to be closed for the streaming software to notice its been updated. 55 | with open(join(this.outdir, name), 'w', encoding='utf-8') as h: 56 | h.write(u'%s\n' % (text or u'')) 57 | h.close() 58 | 59 | 60 | # Write placeholder values for positioning 61 | def plugin_start3(plugin_dir): 62 | write_all() 63 | 64 | # Write placeholder values for positioning 65 | def plugin_start(): 66 | write_all() 67 | 68 | 69 | # Write all files in new location if output directory changed 70 | def prefs_changed(cmdr, is_beta): 71 | if this.outdir != config.get('outdir'): 72 | this.outdir = config.get('outdir') 73 | write_all() 74 | 75 | 76 | # Write any files with changed data 77 | def journal_entry(cmdr, is_beta, system, station, entry, state): 78 | 79 | if this.system != system: 80 | this.system = system 81 | write_file('EDMC System.txt', this.system) 82 | 83 | if 'StarPos' in entry and this.starpos != tuple(entry['StarPos']): 84 | this.starpos = tuple(entry['StarPos']) 85 | write_file('EDMC StarPos.txt', '%s %s %s' % ( 86 | Locale.stringFromNumber(this.starpos[0], 5), 87 | Locale.stringFromNumber(this.starpos[1], 5), 88 | Locale.stringFromNumber(this.starpos[2], 5))) 89 | 90 | if this.station != station: 91 | this.station = station 92 | write_file('EDMC Station.txt', this.station) 93 | 94 | if entry['event'] in ['FSDJump', 'LeaveBody', 'Location', 'SupercruiseEntry', 'SupercruiseExit'] and entry.get('BodyType') in [None, 'Station']: 95 | if this.body: 96 | this.body = None 97 | write_file('EDMC Body.txt') 98 | elif 'Body' in entry: # StartUp, ApproachBody, Location, SupercruiseExit 99 | if this.body != entry['Body']: 100 | this.body = entry['Body'] 101 | write_file('EDMC Body.txt', this.body) 102 | elif entry['event'] == 'StartUp': 103 | this.body = None 104 | write_file('EDMC Body.txt') 105 | 106 | if this.stationorbody != (this.station or this.body): 107 | this.stationorbody = (this.station or this.body) 108 | write_file('EDMC Station or Body.txt', this.stationorbody) 109 | 110 | if this.stationorbodyorsystem != (this.station or this.body or this.system): 111 | this.stationorbodyorsystem = (this.station or this.body or this.system) 112 | write_file('EDMC Station or Body or System.txt', this.stationorbodyorsystem) 113 | 114 | if this.shiptype != state['ShipType']: 115 | this.shiptype = state['ShipType'] 116 | write_file('EDMC ShipType.txt', ship_map.get(this.shiptype, this.shiptype)) 117 | 118 | if this.shipname != (state['ShipName'] or this.shiptype): 119 | this.shipname = (state['ShipName'] or this.shiptype) 120 | write_file('EDMC ShipName.txt', state['ShipName'] and state['ShipName'] or ship_map.get(this.shiptype, this.shiptype)) 121 | 122 | 123 | # Write any files with changed data 124 | def dashboard_entry(cmdr, is_beta, entry): 125 | if 'Latitude' in entry and 'Longitude' in entry: 126 | if this.latlon != (entry['Latitude'], entry['Longitude']): 127 | this.latlon = (entry['Latitude'], entry['Longitude']) 128 | write_file('EDMC LatLon.txt', '%s %s' % ( 129 | Locale.stringFromNumber(this.latlon[0], 6), 130 | Locale.stringFromNumber(this.latlon[1], 6))) 131 | elif this.latlon: 132 | this.latlon = None 133 | write_file('EDMC LatLon.txt') 134 | --------------------------------------------------------------------------------