Youtube Playlist link id´s finder

    • VB.NET
    • .NET (FX) 4.0

      Youtube Playlist link id´s finder

      Hey
      Ich hab mir bei ner kleinen übung mit regex nen youtube playlist id finder gebastelt, das ist dabei rausgekommen :D
      Der thread-sub:

      Quellcode

      1. Public Sub Playlisttoarray(ByVal Playlid As String)
      2. Dim wc As New Net.WebClient
      3. wc.Proxy = Nothing
      4. Dim value As String = wc.DownloadString("http://www.youtube.com/playlist?list=" & Playlid)
      5. Dim r = Regex.Matches(value, "data-video-ids="".*?"" role=""button"">")
      6. Dim key As String = ""
      7. Dim rr As String = r.Item(1).Value
      8. key = rr.Replace(""" role=""button"">", "").Replace("data-video-ids=""", "")
      9. Dim c As Integer = 0
      10. Dim playlist As String = wc.DownloadString("http://www.youtube.com/watch?v=" & key & "&list=" & Playlid)
      11. Dim getr = Regex.Matches(playlist, "data-video-id="".*?""")
      12. Dim feddichid(0 To getr.Count - 1) As String
      13. If getr.Count = 0 Then
      14. Threading.Thread.Sleep(500)
      15. Dim th As New Threading.Thread(AddressOf Playlisttoarray)
      16. th.Start(Playlid)
      17. Exit Sub
      18. Else
      19. For i = 0 To getr.Count - 1
      20. Dim tmp As String = getr.Item(i).Value
      21. feddichid(i) = tmp.Replace("data-video-id=""", "").Replace("""", "")
      22. Next
      23. End If
      24. MsgBox(feddichid(0))
      25. End Sub

      Und so startet man das:

      Quellcode

      1. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
      2. Dim th As New Threading.Thread(AddressOf Playlisttoarray)
      3. th.Start("PLxnuBHTha_MIIqkZ06JyHE8pv7dbLTRl_")
      4. End Sub

      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 :)