only playing with goear

fanfalveto

Active Member
Licensed User
Longtime User
how can see that
B4X:
#Region Module Attributes
   #FullScreen: False
   #IncludeTitle: True
   #ApplicationLabel: por la cara
   #VersionCode: 1
   #VersionName: 
   #SupportedOrientations: unspecified
   #CanInstallToExternalStorage: True
#End Region

Sub Process_Globals
   Dim MainUrl As String
   MainUrl = "http://www.goear.com/search/mano-negra/"
   Dim lista As List
End Sub

Sub Globals
   Dim btnConnect As Button
   Dim ListView1 As ListView
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("1")
   HttpUtils.CallbackActivity = "Main"
   HttpUtils.CallbackJobDoneSub = "JobDone"
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub btnConnect_Click
   HttpUtils.CallbackUrlDoneSub = "" 'don't want to handle this event
   HttpUtils.Download("Main page", MainUrl)
   ProgressDialogShow("Buscando...")
End Sub

Sub Activity_Resume
   'This is important as it is possible that the activity was in the background when the job has finished.
   If HttpUtils.Complete Then JobDone(HttpUtils.Job)
End Sub

'Usually we will want to have a single JobDone sub for all jobs.
'This allows us to check HttpUtils.Complete flag in Activity_Resume (as shown above).
Sub JobDone(Job As String)
   Select Job
      Case "Main page"
         HandleMainPage
      Case "Images"
   End Select
   HttpUtils.Complete = False
End Sub
Sub HandleMainPage
   If HttpUtils.IsSuccess(MainUrl) = False Then
      ToastMessageShow("Error downloading main page.", True)
      Return
   End If
   start = DateTime.Now
   Dim TextReader1 As TextReader
   TextReader1.Initialize(HttpUtils.GetInputStream(MainUrl))
   Log("aaa"&TextReader1)
Dim ini,fin As Int
   Dim line As String
   Dim dir As String
   line = TextReader1.ReadLine
   Do While line <> Null
      line = TextReader1.ReadLine   
Try
ini=line.IndexOf(" href=")
fin=line.IndexOf2("><span class",ini)
dir=line.SubString2(ini+6,fin-1)
Log (dir)
ListView1.AddSingleLine(dir)
   Catch
   End Try
   Loop
   TextReader1.Close
   Log("cargado en: " & ((DateTime.Now - start)/60) & " segundos")
   btnConnect.Enabled = False
   ProgressDialogHide
End Sub
'Show the second activity with the chosen image.
Sub ListView1_ItemClick (Position As Int, Value As Object)
End Sub
this is from a code by erel
only for
B4X:
http://www.goear.com/search/mano-negra/
the line in html is
B4X:
<li ><a title="Escuchar Santa Maradona - mano negra" href="listen/a2e1809/santa-maradona-mano-negra"><span class="songtitleinfo">Santa Maradona</span> - <span class="groupnameinfo">mano negra</span></a>  <a class="play" lang="en" xml:lang="en" title="Escuchar en una ventana independiente" onclick="window.open('http://www.goear.com/listen_popup.php?v=a2e1809','','width=800,height=450,resizable=yes')" href="javascript:void(0);"><img alt="Play" src="http://www.goear.com/lib/img/popup.png" /></a><p class="comment"> 128 kbps | mano negra (manu chao)</p><span class="length">3:16</span></li><li class="even"><a title="Escuchar Mala Vida - mano negra" href="listen/ff60727/mala-vida-mano-negra"><span class="songtitleinfo">Mala Vida</span> - <span class="groupnameinfo">mano negra</span></a>  <a class="play" lang="en" xml:lang="en" title="Escuchar en una ventana independiente" onclick="window.open('http://www.goear.com/listen_popup.php?v=ff60727','','width=800,height=450,resizable=yes')" href="javascript:void(0);"><img alt="Play" src="http://www.goear.com/lib/img/popup.png" /></a><p class="comment"> 144 kbps | mano negra rocks!</p><span class="length">2:52</span></li><li ><a title="Escuchar Machine Gun - mano negra" href="listen/ed15597/machine-gun-mano-negra"><span class="songtitleinfo">Machine Gun</span> - <span class="groupnameinfo">mano negra</span></a>  <a class="play" lang="en" xml:lang="en" title="Escuchar en una ventana independiente" onclick="window.open('http://www.goear.com/listen_popup.php?v=ed15597','','width=800,height=450,resizable=yes')" href="javascript:void(0);"><img alt="Play" src="http://www.goear.com/lib/img/popup.png" /></a><p class="comment"> 122 kbps | mano negra rocks!</p><span class="length">4:25</span></li><li class="even"><a title="Escuchar El se&ntilde;or matanza - mano negra" href="listen/578741c/el-senor-matanza-mano-negra"><span class="songtitleinfo">El se&ntilde;or matanza</span> - <span class="groupnameinfo">mano negra</span></a>  <a class="play" lang="en" xml:lang="en" title="Escuchar en una ventana independiente" onclick="window.open('http://www.goear.com/listen_popup.php?v=578741c','','width=800,height=450,resizable=yes')" href="javascript:void(0);"><img alt="Play" src="http://www.goear.com/lib/img/popup.png" /></a><p class="comment"> 128 kbps | el puto brujo</p><span class="length">4:06</span></li><li ><a title="Escuchar King Kong Five - mano negra" href="listen/6fc05d3/king-kong-five-mano-negra"><span class="songtitleinfo">King Kong Five</span> - <span class="groupnameinfo">mano negra</span></a>  <a class="play" lang="en" xml:lang="en" title="Escuchar en una ventana independiente" onclick="window.open('http://www.goear.com/listen_popup.php?v=6fc05d3','','width=800,height=450,resizable=yes')" href="javascript:void(0);"><img alt="Play" src="http://www.goear.com/lib/img/popup.png" /></a><p class="comment"> 141 kbps | temazo de mano negra del disco grandes exitos</p><span class="length">1:56</span></li><li class="even"><a title="Escuchar La vida - mano negra" href="listen/2e5cf18/la-vida-mano-negra"><span class="songtitleinfo">La vida</span> - <span class="groupnameinfo">mano negra</span></a>  <a class="play" lang="en" xml:lang="en" title="Escuchar en una ventana independiente" onclick="window.open('http://www.goear.com/listen_popup.php?v=2e5cf18','','width=800,height=450,resizable=yes')" href="javascript:void(0);"><img alt="Play" src="http://www.goear.com/lib/img/popup.png" /></a><p class="comment"> 106 kbps | los putos amos!</p><span class="length">2:42</span></li><li ><a title="Escuchar Mala vida - mano negra" href="listen/d66e804/mala-vida-mano-negra"><span class="songtitleinfo">Mala vida</span> - <span class="groupnameinfo">mano negra</span></a>  <a class="play" lang="en" xml:lang="en" title="Escuchar en una ventana independiente" onclick="window.open('http://www.goear.com/listen_popup.php?v=d66e804','','width=800,height=450,resizable=yes')" href="javascript:void(0);"><img alt="Play" src="http://www.goear.com/lib/img/popup.png" /></a><p class="comment"> 139 kbps | t&uacute; me est&aacute;s dando mala vida!</p><span class="length">2:52</span></li><li class="even"><a title="Escuchar Love &amp; Hate - mano negra" href="listen/8c6f15f/love-and-hate-mano-negra"><span class="songtitleinfo">Love &amp; Hate</span> - <span class="groupnameinfo">mano negra</span></a>  <a class="play" lang="en" xml:lang="en" title="Escuchar en una ventana independiente" onclick="window.open('http://www.goear.com/listen_popup.php?v=8c6f15f','','width=800,height=450,resizable=yes')" href="javascript:void(0);"><img alt="Play" src="http://www.goear.com/lib/img/popup.png" /></a><p class="comment"> 119 kbps | casa babylon</p><span class="length">2:29</span></li><li ><a title="Escuchar Pas assez de toi - mano negra" href="listen/c60691f/pas-assez-de-toi-mano-negra"><span class="songtitleinfo">Pas assez de toi</span> - <span class="groupnameinfo">mano negra</span></a>  <a class="play" lang="en" xml:lang="en" title="Escuchar en una ventana independiente" onclick="window.open('http://www.goear.com/listen_popup.php?v=c60691f','','width=800,height=450,resizable=yes')" href="javascript:void(0);"><img alt="Play" src="http://www.goear.com/lib/img/popup.png" /></a><p class="comment"> 129 kbps | a ver si alguien se lo curra y sube algo de manu chao :)</p><span class="length">2:19</span></li><li class="even"><a title="Escuchar Guayaquil City - mano negra" href="listen/f4e059e/guayaquil-city-mano-negra"><span class="songtitleinfo">Guayaquil City</span> - <span class="groupnameinfo">mano negra</span></a>  <a class="play" lang="en" xml:lang="en" title="Escuchar en una ventana independiente" onclick="window.open('http://www.goear.com/listen_popup.php?v=f4e059e','','width=800,height=450,resizable=yes')" href="javascript:void(0);"><img alt="Play" src="http://www.goear.com/lib/img/popup.png" /></a><p class="comment"> 130 kbps | oye pana! que pasa por la calle?</p><span class="length">3:01</span></li>          </ol><!-- los resultados se mostrarán de 10 en 10 -->
and i want this
B4X:
listen/a2e1809/santa-maradona-mano-negra"
thank you
 

walterf25

Expert
Licensed User
Longtime User
EarGo

This works for me! but i think it is better for you to use HttpsUtils2

B4X:
Sub Process_Globals
    Dim MainUrl As String
    MainUrl = "http://www.goear.com/search/mano-negra/"
    Dim lista As List
End Sub

Sub Globals
    Dim btnConnect As Button
    Dim ListView1 As ListView
   Dim job1 As HttpJob 
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("1")   
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub btnConnect_Click
job1.Initialize("Main page", Me)
job1.Download(MainUrl)
End Sub

Sub Activity_Resume
    'This is important as it is possible that the activity was in the background when the job has finished.

End Sub

'Usually we will want to have a single JobDone sub for all jobs.
'This allows us to check HttpUtils.Complete flag in Activity_Resume (as shown above).
Sub JobDone(job As HttpJob)
    Select job.JobName
        Case "Main page"
            HandleMainPage(job)
        Case "Images"
    End Select
  
End Sub
Sub HandleMainPage (job As HttpJob)
    If job.Success = False Then
        ToastMessageShow("Error downloading main page.", True)
        Return
    End If
    start = DateTime.Now
    Dim TextReader1 As TextReader
    TextReader1.Initialize(job.GetInputStream)
  '  Log("aaa"&TextReader1)
Dim ini,fin As Int
    Dim line As String
    Dim dir As String
    line = TextReader1.ReadLine
    Do While line <> Null
        line = TextReader1.ReadLine    
Try
ini=line.IndexOf(" href=")
fin=line.IndexOf2("><span class",ini)
dir=line.SubString2(ini+6,fin-1)
Log ("Line found: " & dir)
If dir.LastIndexOf("listen") > -1 Then
ListView1.AddSingleLine(dir)
End If
    Catch
    End Try
    Loop
    TextReader1.Close
    Log("cargado en: " & ((DateTime.Now - start)/60) & " segundos")
    btnConnect.Enabled = False
    ProgressDialogHide
End Sub
'Show the second activity with the chosen image.
Sub ListView1_ItemClick (Position As Int, Value As Object)
End Sub

Cheers,
Walter
 
Upvote 0

fanfalveto

Active Member
Licensed User
Longtime User
First thank you for httpjob,httputilservice and downloadmanager :sign0098:.
Whit this can download an mp3,but in
B4X:
Sub HandleMainPage (job As HttpJob)
only can put in listview the first result,any idea how to put 10 (is the result of the search in
B4X:
MainUrl = "http://www.goear.com/search/ac-dc/"
B4X:
#Region Module Attributes
   #FullScreen: False
   #IncludeTitle: True
   #ApplicationLabel: por la cara
   #VersionCode: 1
   #VersionName: 
   #SupportedOrientations: unspecified
   #CanInstallToExternalStorage: True
#End Region

Sub Process_Globals
    Dim MainUrl As String
    MainUrl = "http://www.goear.com/search/ac-dc/"
    Dim lista As List
   Dim otrourl As String 
   Dim dir2 As String
      Dim DownloadId As Long
      Dim linea,codigo As String
      Dim line As String
    Dim dir As String
End Sub

Sub Globals
    Dim btnConnect As Button
    Dim ListView1 As ListView
    Dim job1 As HttpJob 
   Dim job2 As HttpJob
   Dim job3 As HttpJob
    Dim DownloadManager1 As DownloadManager
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("1")    
DownloadManager1.RegisterReceiver("DownloadManager1")

   If Utils.IsInitialized=False Then
      Utils.Initialize(DownloadManager1)
   End If

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub btnConnect_Click
ProgressDialogShow("Buscando...")
job1.Initialize("Main page", Me)
job1.Download(MainUrl)
End Sub

Sub Activity_Resume
    'This is important as it is possible that the activity was in the background when the job has finished.

End Sub

'Usually we will want to have a single JobDone sub for all jobs.
'This allows us to check HttpUtils.Complete flag in Activity_Resume (as shown above).
Sub JobDone(job As HttpJob)
    Select job.JobName
        Case "Main page"
            HandleMainPage(job)
        Case "descarga"
      HandleMainPage2(job)
'      Case "baja"
'      HandleMainPage3(job)
    End Select
  
End Sub
Sub HandleMainPage2 (job As HttpJob)
    If job.Success = False Then
        ToastMessageShow("Error downloading main page.", True)
        Return
    End If
    start = DateTime.Now
    Dim TextReader2 As TextReader
    TextReader2.Initialize(job.GetInputStream)
  '  Log("aaa"&TextReader1)
Dim ini2,fin2 As Int
Dim ini22,fin22 As Int
    Dim line2 As String
  Dim nombre As String
'    line = TextReader1.ReadLine
'   Log(line)
    Do While line2 <> Null
        line2 = TextReader2.ReadLine  
      Log(line2)
Try
ini2=line2.IndexOf("song path=")
fin2=line2.IndexOf2(" bild=",ini2)
dir2=line2.SubString2(ini2+11,fin2-1)
Log ("encontado: " & dir2)
'If dir2.LastIndexOf("listen") > -1 Then
'ListView1.AddSingleLine(dir2)
'End If
    Catch
    End Try
    Loop
    TextReader2.Close
    Log("cargado en: " & ((DateTime.Now - start)/60) & " segundos")
   Try
   
ini22=dir.IndexOf2("/",9)

nombre=dir.SubString2(ini22+1,dir.Length)
Log ("nombre: " & nombre)
'If dir2.LastIndexOf("listen") > -1 Then
'ListView1.AddSingleLine(dir2)
'End If
    Catch
    End Try
Dim DownloadManagerRequest1 As DownloadManagerRequest
   DownloadManagerRequest1.Initialize(dir2)
   DownloadManagerRequest1.Description="DownloadManager demo"
   DownloadManagerRequest1.DestinationUri="file://"&File.Combine(File.DirRootExternal,nombre& ".mp3")
   DownloadManagerRequest1.Title=nombre&".mp3"
   DownloadManagerRequest1.VisibleInDownloadsUi=True
   
   DownloadId=DownloadManager1.Enqueue(DownloadManagerRequest1)
    ProgressDialogHide
End Sub
Sub DownloadManager1_DownloadComplete(DownloadId1 As Long)
   If DownloadId=DownloadId1 Then
      Dim DownloadManagerQuery1 As DownloadManagerQuery
      DownloadManagerQuery1.Initialize
      DownloadManagerQuery1.SetFilterById(DownloadId)
      '   you must enable the SQL library to work with the Cursor object
      Dim StatusCursor As Cursor
      '   pass our DownloadManagerQuery to the DownloadManager
      StatusCursor=DownloadManager1.Query(DownloadManagerQuery1)
      If StatusCursor.RowCount>0 Then
         StatusCursor.Position=0      
         Dim StatusInt As Int
         StatusInt=StatusCursor.getInt(DownloadManager1.COLUMN_STATUS)
         Log("Download Status = "&Utils.GetStatusText(StatusInt))
         If StatusInt=DownloadManager1.STATUS_FAILED OR StatusInt=DownloadManager1.STATUS_PAUSED Then
            Dim ReasonInt As Int
            ReasonInt=StatusCursor.GetInt(DownloadManager1.COLUMN_REASON)
            Log("Status Reason = "&Utils.GetReasonText(ReasonInt))
         End If
         If StatusInt=DownloadManager1.STATUS_SUCCESSFUL Then
            Log("bajada ok")
         End If         
      Else
         '   always check that the Cursor returned from the DownloadManager Query method is not empty
         Log("The DownloadManager has no trace of our request, it could have been cancelled by the user using the Android Downloads app or an unknown error has occurred.")
      End If      
      '   free system resources
      StatusCursor.Close
      DownloadManager1.UnregisterReceiver
   End If
   
End Sub

Sub HandleMainPage (job As HttpJob)
    If job.Success = False Then
        ToastMessageShow("Error downloading main page.", True)
        Return
    End If
    start = DateTime.Now
    Dim TextReader1 As TextReader
    TextReader1.Initialize(job.GetInputStream)
  '  Log("aaa"&TextReader1)
Dim ini,fin As Int
    
'    line = TextReader1.ReadLine
'   Log(line)
    Do While line <> Null
        line = TextReader1.ReadLine  
'      Log(line)
Try
ini=line.IndexOf(" href=")
fin=line.IndexOf2("><span class",ini)
dir=line.SubString2(ini+7,fin-1)
Log ("Line found: " & dir)
If dir.LastIndexOf("listen") > -1 Then
ListView1.AddSingleLine(dir)
End If

    Catch
    End Try
    Loop
    TextReader1.Close
    Log("cargado en: " & ((DateTime.Now - start)/60) & " segundos")
    btnConnect.Enabled = False
    ProgressDialogHide
End Sub
Sub ListView1_ItemClick (Position As Int, Value As Object)
'Dim linea,codigo As String
Dim iin,fi As Int
linea=ListView1.GetItem(Position)
Log(linea)
iin=linea.IndexOf("listen/")
Log(iin)
fi=linea.IndexOf2("/",iin+8)
Log(fi)
codigo=linea.SubString2(iin+7,fi)
Log(codigo)
otrourl="http://www.goear.com/tracker758.php?f="&codigo
Log(otrourl)
job2.Initialize("descarga", Me)
job2.Download(otrourl)
   
End Sub
Thank you
 
Upvote 0

fanfalveto

Active Member
Licensed User
Longtime User
this is the problem,i want to extract all chains with this
B4X:
ini=line.IndexOf(" href=")
      fin=line.IndexOf2("><span class",ini)
      dir=line.SubString2(ini+7,fin-1)
      Log ("Line found: " & dir)
      If dir.LastIndexOf("listen") > -1 Then
         ListView1.AddSingleLine(dir)         
      End If
from
B4X:
            <li ><a title="Escuchar Santa Maradona - mano negra" href="[B]listen/a2e1809/santa-maradona-mano-negra[/B]"><span class="songtitleinfo">Santa Maradona</span> - <span class="groupnameinfo">mano negra</span></a>  <a class="play" lang="en" xml:lang="en" title="Escuchar en una ventana independiente" onclick="window.open('http://www.goear.com/listen_popup.php?v=a2e1809','','width=800,height=450,resizable=yes')" href="javascript:void(0);"><img alt="Play" src="http://www.goear.com/lib/img/popup.png" /></a><p class="comment"> 128 kbps | mano negra (manu chao)</p><span class="length">3:16</span></li><li class="even"><a title="Escuchar Mala Vida - mano negra" href="listen/ff60727/mala-vida-mano-negra"><span class="songtitleinfo">Mala Vida</span> - <span class="groupnameinfo">mano negra</span></a>  <a class="play" lang="en" xml:lang="en" title="Escuchar en una ventana independiente" onclick="window.open('http://www.goear.com/listen_popup.php?v=ff60727','','width=800,height=450,resizable=yes')" href="javascript:void(0);"><img alt="Play" src="http://www.goear.com/lib/img/popup.png" /></a><p class="comment"> 144 kbps | mano negra rocks!</p><span class="length">2:52</span></li><li ><a title="Escuchar Machine Gun - mano negra" href="listen/ed15597/machine-gun-mano-negra"><span class="songtitleinfo">Machine Gun</span> - <span class="groupnameinfo">mano negra</span></a>  <a class="play" lang="en" xml:lang="en" title="Escuchar en una ventana independiente" onclick="window.open('http://www.goear.com/listen_popup.php?v=ed15597','','width=800,height=450,resizable=yes')" href="javascript:void(0);"><img alt="Play" src="http://www.goear.com/lib/img/popup.png" /></a><p class="comment"> 122 kbps | mano negra rocks!</p><span class="length">4:25</span></li><li class="even"><a title="Escuchar El se&ntilde;or matanza - mano negra" href="listen/578741c/el-senor-matanza-mano-negra"><span class="songtitleinfo">El se&ntilde;or matanza</span> - <span class="groupnameinfo">mano negra</span></a>  <a class="play" lang="en" xml:lang="en" title="Escuchar en una ventana independiente" onclick="window.open('http://www.goear.com/listen_popup.php?v=578741c','','width=800,height=450,resizable=yes')" href="javascript:void(0);"><img alt="Play" src="http://www.goear.com/lib/img/popup.png" /></a><p class="comment"> 128 kbps | el puto brujo</p><span class="length">4:06</span></li><li ><a title="Escuchar King Kong Five - mano negra" href="listen/6fc05d3/king-kong-five-mano-negra"><span class="songtitleinfo">King Kong Five</span> - <span class="groupnameinfo">mano negra</span></a>  <a class="play" lang="en" xml:lang="en" title="Escuchar en una ventana independiente" onclick="window.open('http://www.goear.com/listen_popup.php?v=6fc05d3','','width=800,height=450,resizable=yes')" href="javascript:void(0);"><img alt="Play" src="http://www.goear.com/lib/img/popup.png" /></a><p class="comment"> 141 kbps | temazo de mano negra del disco grandes exitos</p><span class="length">1:56</span></li><li class="even"><a title="Escuchar La vida - mano negra" href="listen/2e5cf18/la-vida-mano-negra"><span class="songtitleinfo">La vida</span> - <span class="groupnameinfo">mano negra</span></a>  <a class="play" lang="en" xml:lang="en" title="Escuchar en una ventana independiente" onclick="window.open('http://www.goear.com/listen_popup.php?v=2e5cf18','','width=800,height=450,resizable=yes')" href="javascript:void(0);"><img alt="Play" src="http://www.goear.com/lib/img/popup.png" /></a><p class="comment"> 106 kbps | los putos amos!</p><span class="length">2:42</span></li><li ><a title="Escuchar Mala vida - mano negra" href="listen/d66e804/mala-vida-mano-negra"><span class="songtitleinfo">Mala vida</span> - <span class="groupnameinfo">mano negra</span></a>  <a class="play" lang="en" xml:lang="en" title="Escuchar en una ventana independiente" onclick="window.open('http://www.goear.com/listen_popup.php?v=d66e804','','width=800,height=450,resizable=yes')" href="javascript:void(0);"><img alt="Play" src="http://www.goear.com/lib/img/popup.png" /></a><p class="comment"> 13
and only i can extract the first
B4X:
listen/a2e1809/santa-maradona-mano-negra
,this is the second
B4X:
listen/ff60727/mala-vida-mano-negra
,there are 10.I tried several things but I can not do it.
Any idea? thanks
 
Upvote 0

fanfalveto

Active Member
Licensed User
Longtime User
i will try, for now i do that and runs ok
B4X:
For nn=0 To 18
   
      ini=line.IndexOf2(" href=",fin)
      fin=line.IndexOf2("><span class",ini)
      dir=line.SubString2(ini+7,fin-1)
      text=texto.Length
      dir3=line.SubString2(ini+22,fin-text-1)
      Log ("Line found: " & dir)
      If dir.LastIndexOf("listen") > -1 Then
      dir3=dir3.Replace("-"," ")
         ListView1.AddSingleLine(dir3)
         lista.Add(dir)
      End If
   Next
thank you.
i post the program after in share your creations
 
Upvote 0
Top