Jump to content

question about reading the audio Play list using autoit


Recommended Posts

hello
Hi dear, I have a question please
I designed a function to read the content of the playlist
I succeeded in that
I have a problem
For VLC player playlists
If the path of the files in Arabic language the path is be as follows
%D8%A3%D8%B0%D9%83%D8%A7%D8%B1%20%D9%88%D8%A3%D8%AF%D8%B9%D9%8A%D8%A9/%D8%A3%D8%B0%D9%83%D8%A7%D8%B1%20%D9%85%D9%86%D9%88%D8%B9%D8%A9/%D8%A3%D8%B0%D9%83%D8%A7%D8%B1%2003.mp3
I did not know how to decrypt this text to be readable
This is the function that i used

func M3UImport($M3UFile)
dim $AM3UItems
local $fileOpen = FileOpen($path, bitOr($FO_OVERWRITE,$FO_CREATEPATH,$FO_ANSI))
_FileReadToArray ($fileOpen, $AM3UItems)
if @error then return setError(1)
local $M3UPath
for $i = 1 to $AM3UItems[0]
$AM3UItems[$i] = stringReplace($AM3UItems[$i], "file:///", "")
$AM3UItems[$i] = stringReplace($AM3UItems[$i], "/", "\")
$AM3UItems[$i] = stringReplace($AM3UItems[$i], "%20", " ")
$M3UPath = _fileGetDirPath($AM3UItems[$i])
if $M3UPath = "" then
$M3UPath = @WorkingDir
if not StringTrimRight($M3UPath, 1) = "\" then $M3UPath &= "\"
$AM3UItems[$i] = $M3UPath & $AM3UItems[$i]
endIf
local $ext = _GetFileExt($AM3UItems[$i])
if fileExists($AM3UItems[$i]) and not (StringInStr($FilesExt, $ext) = 0) then
$aListItems[0] += 1
GUICtrlCreateListViewItem(_GetFileName($AM3UItems[$i]) & Opt("GUIDataSeparatorChar") & " : " & Opt("GUIDataSeparatorChar") & $AM3UItems[$i], $list)
endIf
next
return ""
endFunc


I ask for your help in this work
with my Greetings and thanks in advance
Link to comment
Share on other sites

Hello. maybe something like this:

#include <Array.au3>
Local $sString = "%D8%A3%D8%B0%D9%83%D8%A7%D8%B1%20%D9%88%D8%A3%D8%AF%D8%B9%D9%8A%D8%A9/%D8%A3%D8%B0%D9%83%D8%A7%D8%B1%20%D9%85%D9%86%D9%88%D8%B9%D8%A9/%D8%A3%D8%B0%D9%83%D8%A7%D8%B1%2003.mp3"

MsgBox(0, "", _MakeReadable($sString))


Func _MakeReadable($sString)
    Local $aReg = StringRegExp($sString, '%[0-9a-fA-F]{2}|.', 3)
    Local $sChar = ""
    Local $sReadableString=""
    For $i = 0 To UBound($aReg) - 1
        $sChar = StringReplace($aReg[$i], "%", "")
        If StringLen($sChar) = 2 Then
            $sReadableString &= Chr("0x" & $sChar)
        Else
            $sReadableString &= $sChar
        EndIf
    Next
    Return BinaryToString(StringToBinary($sReadableString), 4)
EndFunc   ;==>_MakeTeadable

Saludos

Link to comment
Share on other sites

When I used this example, it just gave me as a result the number 3 only
Is there a solution please?

#include <Array.au3>
Local $sString = "%D8%A3%D8%B0%D9%83%D8%A7%D8%B1%20%D9%88%D8%A3%D8%AF%D8%B9%D9%8A%D8%A9/%D8%A3%D8%B0%D9%83%D8%A7%D8%B1%20%D9%85%D9%86%D9%88%D8%B9%D8%A9/%D8%A3%D8%B0%D9%83%D8%A7%D8%B1%2003.mp3"
MsgBox(0, "", _MakeReadable($sString))
Func _MakeReadable($sString)
Local $aReg = StringRegExp($sString, '%[0-9a-fA-F]{2}|.', 3)
    Local $sChar = ""
    Local $sReadableString=""
    For $i = 0 To UBound($aReg) - 1
$sChar = StringReplace($aReg[$i], "%", "")
If StringLen($sChar) = 2 Then
$sReadableString = Chr("0x" & $sChar)
Else
$sReadableString = $sChar
EndIf
Next
Return BinaryToString(StringToBinary($sReadableString), 4)
EndFunc


am waiting
:D

 

Link to comment
Share on other sites

$sReadableString = Chr("0x" & $sChar) needs to be $sReadableString &= Chr("0x" & $sChar) and $sReadableString = $sChar needs to be $sReadableString &= $sChar

 

 

Saludos

Link to comment
Share on other sites

Link to comment
Share on other sites


i ded what you tell me but the result is 3
this is the function

#include <Array.au3>
Local $sString = "%D8%A3%D8%B0%D9%83%D8%A7%D8%B1%20%D9%88%D8%A3%D8%AF%D8%B9%D9%8A%D8%A9/%D8%A3%D8%B0%D9%83%D8%A7%D8%B1%20%D9%85%D9%86%D9%88%D8%B9%D8%A9/%D8%A3%D8%B0%D9%83%D8%A7%D8%B1%2003.mp3"
MsgBox(0, "", _MakeReadable($sString))
Func _MakeReadable($sString)
Local $aReg = StringRegExp($sString, '%[0-9a-fA-F]{2}|.', 3)
    Local $sChar = ""
    Local $sReadableString=""
    For $i = 0 To UBound($aReg) - 1
$sChar = StringReplace($aReg[$i], "%", "")
If StringLen($sChar) = 2 Then
$sReadableString = Chr("0x" & $sChar)
Else
$sReadableString = $sChar
EndIf
Next
Return BinaryToString(StringToBinary($sReadableString), 4)
EndFunc

Link to comment
Share on other sites

@nacerbaaziz

Because you use a screen reader, the ampersands are probably not getting translated correctly because they are immediately before an equal sign.  To make the function work correctly, you need to modify 2 lines that were not transcribed correctly.  Those 2 lines are below.

 

21 hours ago, nacerbaaziz said:

$sReadableString = Chr("0x" & $sChar)

 

21 hours ago, nacerbaaziz said:

$sReadableString = $sChar

On the 2 lines above, there should be an ampersand immediately before the equal sign (without a space in between).  The operator should read ampersand equal.

I hope that helps.

Link to comment
Share on other sites

Hello
it's worked with me, thank you very much
Now I have a simple request if you can help me please
the question Is how I can know if the string as   this type or normal string
I have to make it detect this type so there is no contradiction between the strings types
I mean the playlist can be in Arabic and it can be in English
I hope that my request is clear for you
Greetings

Link to comment
Share on other sites

@nacerbaaziz

You can either use @Danyfirex's function on all titles to make sure they are converted if necessary or you can search each title for an ampersand followed by 2 numeric digits, and if found, use the function.  The safest and most efficient way would be to do the check for the escape sequences and only convert if necessary.

Link to comment
Share on other sites

I've written the function as this form, please give me your opinion.

Func _MakeReadable($sString)
Local $aReg = StringRegExp($sString, '%[0-9a-fA-F]{2}|.', 3)
    Local $sChar = ""
    Local $sReadableString=""
local $number = 0
For $i = 0 To UBound($aReg) - 1
$sChar = StringReplace($aReg[$i], "%", "")
If StringLen($sChar) = 2 Then
$sReadableString &= Chr("0x" & $sChar)
$number += 1
Else
$sReadableString &= $sChar
$number -= 1
EndIf
Next
if $number < 2 then
return string($sReadableString)
else
Return BinaryToString(StringToBinary($sReadableString), 4)
endIf
EndFunc

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...