home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 6_2008-2009.ISO / data / zips / Video_Grab213908122009.psc / parse.bas < prev    next >
BASIC Source File  |  2009-01-01  |  5KB  |  217 lines

  1. Attribute VB_Name = "parse_funcs"
  2. Option Explicit
  3.  
  4. Type fileInfo
  5.     id As String
  6.     url As String
  7.     directurl As String
  8.     title As String
  9. End Type
  10.  
  11. Private Type tagInitCommonControlsEx
  12.    lngSize As Long
  13.    lngICC As Long
  14. End Type
  15.  
  16. Private Declare Function InitCommonControlsEx Lib "comctl32.dll" _
  17.    (iccex As tagInitCommonControlsEx) As Boolean
  18. Private Const ICC_USEREX_CLASSES = &H200
  19.  
  20. Public Function InitCommonControlsVB() As Boolean
  21.    On Error Resume Next
  22.    Dim iccex As tagInitCommonControlsEx
  23.    ' Ensure CC available:
  24.    With iccex
  25.        .lngSize = LenB(iccex)
  26.        .lngICC = ICC_USEREX_CLASSES
  27.    End With
  28.    InitCommonControlsEx iccex
  29.    InitCommonControlsVB = (Err.Number = 0)
  30.    On Error GoTo 0
  31. End Function
  32.  
  33.  
  34. Function checkSite(vUrl As String)
  35.     Dim checkSiteName As Integer
  36.     
  37.     checkSiteName = InStr(1, vUrl, "youtube.com")
  38.     If checkSiteName <= 0 Then
  39.         checkSiteName = InStr(1, vUrl, "facebook.com")
  40.         If checkSiteName <= 0 Then
  41.             MsgBox xmlDoc.langVar(0).strFull(17), vbOKOnly + vbInformation + vbSystemModal, "Video Grabber"
  42.         Else
  43.             checkSite = "facebook"
  44.         End If
  45.     Else
  46.        checkSite = "youtube"
  47.     End If
  48. End Function
  49.  
  50. Function ReadConfFile()
  51.     Dim confFile As String
  52.     Dim fbUser As String
  53.     Dim fbPass As String
  54.     Dim fbSaveSettings As String
  55.     
  56.     confFile = App.Path + "\config\config.cfg"
  57.     
  58.     Dim freeFileID
  59.     freeFileID = FreeFile
  60.     
  61.     Open confFile For Input As #freeFileID
  62.         Input #freeFileID, fbUser
  63.         Input #freeFileID, fbPass
  64.         Input #freeFileID, fbSaveSettings
  65.     Close #freeFileID
  66.     
  67.     fbUser = URLDecode(grabData(fbUser))
  68.     fbPass = URLDecode(grabData(fbPass))
  69.     fbSaveSettings = grabData(fbSaveSettings)
  70.     
  71.     Form1.Text2.Text = fbUser
  72.     Form1.Text3.Text = fbPass
  73.     If fbSaveSettings = "yes" Then
  74.         Form1.Check1.Value = vbChecked
  75.     Else
  76.         Form1.Check1.Value = vbUnchecked
  77.     End If
  78.     
  79. End Function
  80.  
  81. Function WriteConfFile()
  82.     Dim confFile As String
  83.     Dim fbUser As String
  84.     Dim fbPass As String
  85.     Dim fbSaveSettings As String
  86.     
  87.     confFile = App.Path + "\config\config.cfg"
  88.     
  89.     
  90.     If Form1.Check1.Value = vbChecked Then
  91.         fbUser = URLEncode(Form1.Text2.Text)
  92.         fbPass = URLEncode(Form1.Text3.Text)
  93.         fbSaveSettings = "yes"
  94.     Else
  95.         fbUser = ""
  96.         fbPass = ""
  97.         fbSaveSettings = "no"
  98.     End If
  99.     
  100.     Dim freeFileID
  101.     freeFileID = FreeFile
  102.     
  103.     Open confFile For Output As #freeFileID
  104.         Print #freeFileID, "fbUser=" & fbUser
  105.         Print #freeFileID, "fbPass=" & fbPass
  106.         Print #freeFileID, "fbSaveSettings=" & fbSaveSettings
  107.     Close #freeFileID
  108.     
  109. End Function
  110. Function loadLangList(objCombo As ComboBox)
  111.     Dim confFile As String
  112.     
  113.     Dim vgLangNames As String
  114.     Dim vgLangFiles As String
  115.     
  116.     Dim vgLangNamesVar() As String
  117.     Dim vgLangFilesVar() As String
  118.     
  119.     Dim langRow
  120.     
  121.     confFile = App.Path + "\config\lang_list.cfg"
  122.     
  123.     Dim freeFileID
  124.     freeFileID = FreeFile
  125.     
  126.     Open confFile For Input As #freeFileID
  127.         Input #freeFileID, vgLangNames
  128.         Input #freeFileID, vgLangFiles
  129.     Close #freeFileID
  130.     
  131.     vgLangNames = grabData(vgLangNames)
  132.     vgLangFiles = grabData(vgLangFiles)
  133.     
  134.     vgLangNamesVar = Split(vgLangNames, ";")
  135.     vgLangFilesVar = Split(vgLangFiles, ";")
  136.     
  137.     For langRow = 0 To UBound(vgLangNamesVar)
  138.         objCombo.AddItem Trim(vgLangNamesVar(langRow)) & "=" & Trim(vgLangFilesVar(langRow))
  139.     Next langRow
  140.     
  141. End Function
  142.  
  143. Function saveLangData(objCombo As ComboBox)
  144.     Dim confFile As String
  145.     Dim strLangFile
  146.     
  147.     strLangFile = grabData(objCombo.Text)
  148.  
  149.     confFile = App.Path + "\config\lang.cfg"
  150.     
  151.     Dim freeFileID
  152.     freeFileID = FreeFile
  153.     
  154.     Open confFile For Output As #freeFileID
  155.         Print #freeFileID, "vgLang=" & strLangFile
  156.     Close #freeFileID
  157. End Function
  158.  
  159. Function grabData(strData As String)
  160.     Dim strStart
  161.     strStart = InStr(1, strData, "=")
  162.     grabData = Mid(strData, strStart + 1, Len(strData) - strStart)
  163. End Function
  164.  
  165. Public Function URLEncode(strEntrada As String) As String
  166.  
  167. Dim i As Long
  168. Dim strSalida As String
  169. Dim Temp As String
  170.  
  171. For i = 1 To Len(strEntrada)
  172. Temp = Mid(strEntrada, i, 1)
  173. 'si queremos que convierta TODOS los caracteres, comentamos las lineas
  174. 'que tienen un ## al final
  175. If Not Temp Like "[a-z,A-Z,0-9]" Then '##
  176. strSalida = strSalida & "%" & Hex(Asc(Temp))
  177. Else '##
  178. strSalida = strSalida & Temp '##
  179. End If '##
  180. Next i
  181.  
  182. URLEncode = strSalida
  183.  
  184. End Function
  185.  
  186. Public Function URLDecode(strEntrada As String) As String
  187.  
  188. Dim strCaracter  As String
  189. Dim strSalida As String
  190. Dim i As Long
  191.  
  192. For i = 1 To Len(strEntrada)
  193. If Mid(strEntrada, i, 1) = "%" Then
  194.  
  195. strCaracter = Mid(strEntrada, i + 1, 2)
  196.  
  197. strSalida = strSalida & Chr(Val("&H" & strCaracter))
  198.  
  199. i = i + 2
  200.  
  201. Else
  202.  
  203. strSalida = strSalida & Mid(strEntrada, i, 1)
  204.  
  205. End If
  206. Next i
  207.  
  208. URLDecode = strSalida
  209.  
  210. End Function
  211.  
  212. Function showState(strState)
  213.     DoEvents
  214.     Form1.Label16.Caption = xmlDoc.langVar(0).strFull(14) & " " & strState
  215.     DoEvents
  216. End Function
  217.