MCPcopy Create free account
hub / github.com/DialmasterOrg/Youtarr / getBaseUrl

Method getBaseUrl

server/modules/plexModule.js:16–39  ·  view source on GitHub ↗
(preferredIp, config, preferredPort, preferredUseHttps)

Source from the content-addressed store, hash-verified

14 constructor() {}
15
16 getBaseUrl(preferredIp, config, preferredPort, preferredUseHttps) {
17 const resolvedConfig = config || configModule.getConfig();
18 const managedUrl = (process.env.PLEX_URL || resolvedConfig.plexUrl || '').trim();
19
20 if (managedUrl) {
21 return managedUrl.replace(/\/+$/, '');
22 }
23
24 const ip = preferredIp || resolvedConfig.plexIP;
25 if (!ip) {
26 return null;
27 }
28
29 const rawPort =
30 preferredPort !== undefined && preferredPort !== null && String(preferredPort).trim() !== ''
31 ? String(preferredPort).trim()
32 : resolvedConfig.plexPort ?? '32400';
33 const numericPort = String(rawPort).replace(/[^0-9]/g, '');
34 const port = numericPort || '32400';
35
36 const useHttps = preferredUseHttps !== undefined ? preferredUseHttps : resolvedConfig.plexViaHttps;
37 const protocol = useHttps ? 'https' : 'http';
38 return `${protocol}://${ip}:${port}`;
39 }
40
41 /**
42 * Get the Plex library ID that should be refreshed for a given resolved subfolder.

Callers 6

refreshLibraryMethod · 0.95
checkPinMethod · 0.95
getEnabledAdaptersMethod · 0.80
plexModule.test.jsFile · 0.80

Calls 1

getConfigMethod · 0.80

Tested by

no test coverage detected