Skip to content

Commit

Permalink
v1.2.3
Browse files Browse the repository at this point in the history
Improvement : Ability to reach the YTuner web service using a different IP address than the actual one belonging to the machine that runs the YTuner process. For more details look ytuner.ini content description.
  • Loading branch information
coffeegreg committed May 20, 2024
1 parent 34fe8f0 commit c62b171
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
12 changes: 6 additions & 6 deletions src/bookmark.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions src/common.pas
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface
{$IFDEF UNIX}
dl,
{$ENDIF}
SQLDBLib, SQLDB, SQLite3Conn;
SQLDBLib, SQLDB, SQLite3Conn, FileUtil;

type
TLogType = (ltNone, ltInfo, ltWarning, ltError, ltDebug);
Expand All @@ -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';
Expand Down Expand Up @@ -106,6 +106,7 @@ interface

var
MyIPAddress: string = DEFAULT_STRING;
URLHost: string = '';
LogType: TLogType = ltError;
MyAppPath: string;
UseSSL: boolean = True;
Expand Down
10 changes: 5 additions & 5 deletions src/httpserver.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand All @@ -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;
Expand Down
10 changes: 8 additions & 2 deletions src/ytuner.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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.

0 comments on commit c62b171

Please # to comment.