Return the output format string to use for this client.
(user, force=None, request=None)
| 54 | |
| 55 | |
| 56 | def _resolve_output_format(user, force=None, request=None): |
| 57 | """Return the output format string to use for this client.""" |
| 58 | _FORMAT_ALIASES = { |
| 59 | 'mpegts': 'mpegts', |
| 60 | 'ts': 'mpegts', |
| 61 | 'fmp4': 'fmp4', |
| 62 | 'mp4': 'fmp4', |
| 63 | } |
| 64 | if force: |
| 65 | return force |
| 66 | if request: |
| 67 | # Support both ?output_format= (native) and ?output= (XC-style) |
| 68 | param = request.GET.get('output_format') or request.GET.get('output') |
| 69 | if param in _FORMAT_ALIASES: |
| 70 | return _FORMAT_ALIASES[param] |
| 71 | if user: |
| 72 | custom = getattr(user, 'custom_properties', None) or {} |
| 73 | user_format = custom.get('output_format') |
| 74 | if user_format: |
| 75 | return user_format |
| 76 | return CoreSettings.get_default_output_format() |
| 77 | |
| 78 | |
| 79 | def _resolve_output_profile(request, user): |
no test coverage detected