diff --git a/src/bookmark.pas b/src/bookmark.pas index e052e83..cdc7287 100644 --- a/src/bookmark.pas +++ b/src/bookmark.pas @@ -85,8 +85,8 @@ function GetBookmark(AMAC: string; AFirstElement, ALastElement: integer; AXMLStr for i:=AFirstElement to ALastElement do begin AppendChild(LXMLBookmarkPart.ImportNode(LXMLBookmark.FirstChild.ChildNodes[i+1],true)); - LastChild.FindNode(VT_XML_LOGO).FirstChild.NodeValue:=StringReplace(LastChild.FindNode(VT_XML_LOGO).FirstChild.NodeValue,YTUNER_HOST,MyIPAddress,[rfIgnoreCase]); - LastChild.FindNode(VT_XML_BOOKMARK).FirstChild.NodeValue:=StringReplace(LastChild.FindNode(VT_XML_BOOKMARK).FirstChild.NodeValue,YTUNER_HOST,MyIPAddress,[rfIgnoreCase]); + LastChild.FindNode(VT_XML_LOGO).FirstChild.NodeValue:=StringReplace(LastChild.FindNode(VT_XML_LOGO).FirstChild.NodeValue,YTUNER_HOST,URLHost,[rfIgnoreCase]); + LastChild.FindNode(VT_XML_BOOKMARK).FirstChild.NodeValue:=StringReplace(LastChild.FindNode(VT_XML_BOOKMARK).FirstChild.NodeValue,YTUNER_HOST,URLHost,[rfIgnoreCase]); end; end; WriteXML(LXMLBookmarkPart,AXMLStream); @@ -139,8 +139,8 @@ function GetBookmarkStationInfo(AMAC, ASID: string; AXMLStream: TStream): boolea with LXMLBookmarkPart.DocumentElement do begin AppendChild(LXMLBookmarkPart.ImportNode(LXMLBookmark.FirstChild.ChildNodes[LStationIdx],true)); - LastChild.FindNode(VT_XML_LOGO).FirstChild.NodeValue:=StringReplace(LastChild.FindNode(VT_XML_LOGO).FirstChild.NodeValue,YTUNER_HOST,MyIPAddress,[rfIgnoreCase]); - LastChild.FindNode(VT_XML_BOOKMARK).FirstChild.NodeValue:=StringReplace(LastChild.FindNode(VT_XML_BOOKMARK).FirstChild.NodeValue,YTUNER_HOST,MyIPAddress,[rfIgnoreCase]); + LastChild.FindNode(VT_XML_LOGO).FirstChild.NodeValue:=StringReplace(LastChild.FindNode(VT_XML_LOGO).FirstChild.NodeValue,YTUNER_HOST,URLHost,[rfIgnoreCase]); + LastChild.FindNode(VT_XML_BOOKMARK).FirstChild.NodeValue:=StringReplace(LastChild.FindNode(VT_XML_BOOKMARK).FirstChild.NodeValue,YTUNER_HOST,URLHost,[rfIgnoreCase]); WriteXML(LXMLBookmarkPart,AXMLStream); end; except @@ -210,8 +210,8 @@ procedure SetBookmark(AMAC, AAction: string; ANode: TDOMNode); LNode.FirstChild.FirstChild.NodeValue:=IntToStr(LItemCount+1); LNode:=LXMLBookmark.ImportNode(ANode,true); LNode.FindNode(VT_XML_BOOKMARK).FirstChild.NodeValue:=StringReplace(LNode.FindNode(VT_XML_BOOKMARK).FirstChild.NodeValue,PATH_FAVACTION+'='+PATH_FAVACTION_ADD,PATH_FAVACTION+'='+PATH_FAVACTION_DEL,[rfIgnoreCase]); - LNode.FindNode(VT_XML_LOGO).FirstChild.NodeValue:=StringReplace(LNode.FindNode(VT_XML_LOGO).FirstChild.NodeValue,MyIPAddress,YTUNER_HOST,[rfIgnoreCase]); - LNode.FindNode(VT_XML_BOOKMARK).FirstChild.NodeValue:=StringReplace(LNode.FindNode(VT_XML_BOOKMARK).FirstChild.NodeValue,MyIPAddress,YTUNER_HOST,[rfIgnoreCase]); + LNode.FindNode(VT_XML_LOGO).FirstChild.NodeValue:=StringReplace(LNode.FindNode(VT_XML_LOGO).FirstChild.NodeValue,URLHost,YTUNER_HOST,[rfIgnoreCase]); + LNode.FindNode(VT_XML_BOOKMARK).FirstChild.NodeValue:=StringReplace(LNode.FindNode(VT_XML_BOOKMARK).FirstChild.NodeValue,URLHost,YTUNER_HOST,[rfIgnoreCase]); LXMLBookmark.DocumentElement.AppendChild(LNode); WriteXMLFile(LXMLBookmark,AMAC); end; diff --git a/src/common.pas b/src/common.pas index e62a6d6..1c6fe78 100644 --- a/src/common.pas +++ b/src/common.pas @@ -11,7 +11,7 @@ interface {$IFDEF UNIX} dl, {$ENDIF} - SQLDBLib, SQLDB, SQLite3Conn; + SQLDBLib, SQLDB, SQLite3Conn, FileUtil; type TLogType = (ltNone, ltInfo, ltWarning, ltError, ltDebug); @@ -20,9 +20,9 @@ interface const APP_NAME = 'YTuner'; - APP_VERSION = '1.2.2'; + APP_VERSION = '1.2.3'; APP_COPYRIGHT = 'Copyright (c) 2024 Greg P. (https://github.com/coffeegreg)'; - INI_VERSION = '1.2.0'; + INI_VERSION = '1.2.1'; YTUNER_USER_AGENT = 'YTuner'; YTUNER_HOST = 'ytunerhost'; @@ -106,6 +106,7 @@ interface var MyIPAddress: string = DEFAULT_STRING; + URLHost: string = ''; LogType: TLogType = ltError; MyAppPath: string; UseSSL: boolean = True; diff --git a/src/httpserver.pas b/src/httpserver.pas index 2c7ae1a..7751bd3 100644 --- a/src/httpserver.pas +++ b/src/httpserver.pas @@ -856,9 +856,9 @@ function SetVTunerStation(LStation: TMSStation; AReq: TRequest): TVTunerStation; Name:=Station.MSName; Description:='My favorite "'+Station.MSName+'"'; URL:=StripHttps(Station.MSURL,AReq); - Icon:=PATH_HTTP+MyIPAddress+'/'+PATH_ROOT+'/'+PATH_ICON+'?'+PATH_PARAM_ID+'='+Station.MSID; + Icon:=PATH_HTTP+URLHost+'/'+PATH_ROOT+'/'+PATH_ICON+'?'+PATH_PARAM_ID+'='+Station.MSID; Genre:=Category; - Bookmark:=PATH_HTTP+MyIPAddress+'/'+PATH_SETUPAPP+'/'+PATH_FAVXML_ASP+'?'+PATH_PARAM_ID+'='+Station.MSID+'&'+PATH_FAVACTION+'='+PATH_FAVACTION_ADD; + Bookmark:=PATH_HTTP+URLHost+'/'+PATH_SETUPAPP+'/'+PATH_FAVXML_ASP+'?'+PATH_PARAM_ID+'='+Station.MSID+'&'+PATH_FAVACTION+'='+PATH_FAVACTION_ADD; end; end; @@ -878,8 +878,8 @@ function SetVTunerStation(LRBStation: TRBStation; AReq: TRequest): TVTunerStatio Location:=RBSCountry; Mime:=RBSCodec.ToUpper; Bitrate:=RBSBitrate; - Icon:=PATH_HTTP+MyIPAddress+'/'+PATH_ROOT+'/'+PATH_ICON+'?'+PATH_PARAM_ID+'='+UID; - Bookmark:=PATH_HTTP+MyIPAddress+'/'+PATH_SETUPAPP+'/'+PATH_FAVXML_ASP+'?'+PATH_PARAM_ID+'='+UID+'&'+PATH_FAVACTION+'='+PATH_FAVACTION_ADD; + Icon:=PATH_HTTP+URLHost+'/'+PATH_ROOT+'/'+PATH_ICON+'?'+PATH_PARAM_ID+'='+UID; + Bookmark:=PATH_HTTP+URLHost+'/'+PATH_SETUPAPP+'/'+PATH_FAVXML_ASP+'?'+PATH_PARAM_ID+'='+UID+'&'+PATH_FAVACTION+'='+PATH_FAVACTION_ADD; end; end; @@ -889,7 +889,7 @@ function SetVTunerDirectory(ATitle, ADestination: string; AItemCount: integer): with Result do begin Title:=ATitle; - Destination:=PATH_HTTP+MyIPAddress+'/'+ADestination; + Destination:=PATH_HTTP+URLHost+'/'+ADestination; ItemCount:=AItemCount; end; end; diff --git a/src/ytuner.pas b/src/ytuner.pas index b6298a3..c6fedfa 100644 --- a/src/ytuner.pas +++ b/src/ytuner.pas @@ -114,6 +114,9 @@ procedure ReadINIConfiguration; if ReadString(INI_CONFIGURATION,'INIVersion','')<>INI_VERSION then Logging(ltWarning, 'You are running out of INI file or your ytuner.ini file is outdated! Some features may not work properly! Check https://github.com/coffeegreg/YTuner/tree/master/cfg for the correct INI file for your version of YTuner'); MyIPAddress:=GetLocalIP(ReadString(INI_CONFIGURATION,'IPAddress',MyIPAddress)); + URLHost:=ReadString(INI_CONFIGURATION,'ActAsHost',MyIPAddress).Replace(DEFAULT_STRING,MyIPAddress); + if URLHost.Trim.IsEmpty then + URLHost:=MyIPAddress; UseSSL:=ReadBool(INI_CONFIGURATION,'UseSSL',True); IconSize:=ReadInteger(INI_CONFIGURATION,'IconSize',IconSize); IconCache:=ReadBool(INI_CONFIGURATION,'IconCache',True); @@ -336,8 +339,11 @@ procedure MoveConfigFiles; Application.Threaded:=True; Application.Initialize; Logging(ltInfo, WEB_SERVICE+': listening on: '+WebServerIPAddress+':'+WebServerPort.ToString); - if MyIPAddress <> WebServerIPAddress then - Logging(ltInfo, 'AVRs HTTP requests IP target: '+MyIPAddress); + if (URLHost <> '') and (URLHost <> WebServerIPAddress) then + Logging(ltInfo, 'AVRs HTTP requests host target: '+URLHost) + else + if MyIPAddress <> WebServerIPAddress then + Logging(ltInfo, 'AVRs HTTP requests IP target: '+MyIPAddress); Application.Run; end.