Hey
Ich hab mir bei ner kleinen übung mit regex nen youtube playlist id finder gebastelt, das ist dabei rausgekommen
Der thread-sub:
Und so startet man das:
Der thread wird daher immer wieder gestartet bis er was hat, weil youtube seinen code "rotieren" lässt, also starte ich die routine so oft bis das richtige da ist
Ich hoffe ihr habt spass damit
Ich hab mir bei ner kleinen übung mit regex nen youtube playlist id finder gebastelt, das ist dabei rausgekommen
Der thread-sub:
Quellcode
- Public Sub Playlisttoarray(ByVal Playlid As String)
- Dim wc As New Net.WebClient
- wc.Proxy = Nothing
- Dim value As String = wc.DownloadString("http://www.youtube.com/playlist?list=" & Playlid)
- Dim r = Regex.Matches(value, "data-video-ids="".*?"" role=""button"">")
- Dim key As String = ""
- Dim rr As String = r.Item(1).Value
- key = rr.Replace(""" role=""button"">", "").Replace("data-video-ids=""", "")
- Dim c As Integer = 0
- Dim playlist As String = wc.DownloadString("http://www.youtube.com/watch?v=" & key & "&list=" & Playlid)
- Dim getr = Regex.Matches(playlist, "data-video-id="".*?""")
- Dim feddichid(0 To getr.Count - 1) As String
- If getr.Count = 0 Then
- Threading.Thread.Sleep(500)
- Dim th As New Threading.Thread(AddressOf Playlisttoarray)
- th.Start(Playlid)
- Exit Sub
- Else
- For i = 0 To getr.Count - 1
- Dim tmp As String = getr.Item(i).Value
- feddichid(i) = tmp.Replace("data-video-id=""", "").Replace("""", "")
- Next
- End If
- MsgBox(feddichid(0))
- End Sub
Und so startet man das:
Der thread wird daher immer wieder gestartet bis er was hat, weil youtube seinen code "rotieren" lässt, also starte ich die routine so oft bis das richtige da ist
Ich hoffe ihr habt spass damit
Wer Rechtschreibfehler findet darf sie behalten