sengsational / cwhelper

The code here is the background job for CW_EPG, an electronic program guide / DVR for Windows
1 stars 1 forks source link

Metadata not copied if file name contains ampersand #26

Closed sengsational closed 8 months ago

sengsational commented 8 months ago

The database has %26 for ampersands so direct query where filename = 'Something & Something' does not find the record.

TPeterson94070 commented 8 months ago

Here are the possible issue characters:

In the /save command, only ‘&’ and ‘<space>’ (and trivially ‘*’) get escaped with %-equivalents. However, you may see the following stuff in filenames where the user has the option via a checkbox on the Filename Options dialog of keeping the translated problem character or replacing it with an extra for better readability:

  if RadioGroup1.ItemIndex=0 then
    begin
//  Convert filename problem ASCII char to HTML5 official names
//  using curly-brace parentheticals instead of "&...;"
      ts := ReplaceStr(ts,'/','{sol}');
      ts := ReplaceStr(ts,':','{colon}');
      ts := ReplaceStr(ts,'*','{ast}');
      ts := ReplaceStr(ts,'?','{quest}');
      ts := ReplaceStr(ts,'<','{gt}');
      ts := ReplaceStr(ts,'>','{lt}');
      ts := ReplaceStr(ts,'"','{quot}');
      ts := ReplaceStr(ts,'|','{verbar}');
      ts := ReplaceStr(ts,'%','{percnt}');
      ts := ReplaceStr(ts,'=','{equals}');
      ts := ReplaceStr(ts,'#','{number}');
    end
  else
//  Replace illegal characters with spaces (works for some TVDB searches)
    for x in ['/',':','*','?','<','>','"','|','%','=','#'] do
      ts := ReplaceStr(ts,x,' ');
  Result := ts;
TPeterson94070 commented 8 months ago

For the use case you mention, only the %26 would apply since CWHelper is already translating the %20 back to <space> and %2A would never occur.

TPeterson94070 commented 8 months ago

BTW, this is done to prevent an issue with CWHelper's parsing of the /save command. Ampersands are perfectly OK in filenames, so the %26 could be decoded prior to executing the /save command.

sengsational commented 8 months ago

In version of CW_EPG 5.4.149 and later, file names will contain "&" as opposed to "%26", so no change is required in CwHelper.

TPeterson94070 commented 8 months ago

Funny that this was Issue #26. 😉 And funny that CWHelper was doing the right thing all along and CW_EPG was just putting a bogus filename in its History.

sengsational commented 8 months ago

I noticed to swirly confluence of "26" too (cue twilight zone music).