Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > .NET Framework > Forum > อยากทำโปรแกรมโหลดวีดีโอจากยูทูบแต่ติดปัญหาที่โค้ดช่วยแก้ให้หน่อยน่ะ ครับ



 

อยากทำโปรแกรมโหลดวีดีโอจากยูทูบแต่ติดปัญหาที่โค้ดช่วยแก้ให้หน่อยน่ะ ครับ

 



Topic : 111138



โพสกระทู้ ( 30 )
บทความ ( 0 )



สถานะออฟไลน์




Code (VB.NET)
Imports System.Net
Imports System.IO
Imports System.Diagnostics
Public Class Form1

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        SaveFileDialog1.FileName = vbNullString
        SaveFileDialog1.ShowDialog()
        If SaveFileDialog1.FileName <> vbNullString Then
            My.Computer.Network.DownloadFile(lstv.SelectedItems(0).Tag, SaveFileDialog1.FileName, _
                                             vbNullString, vbNullString, True, 5000, True)
        End If
    End Sub

    Private Function ParseLike(ByVal url As String) As String
        Dim i As Long
        Dim ToRep As String
        Dim tmp As String
        Dim theC As String
        For i = 1 To Len(url) - 1
            tmp = Mid(url, i, 1)
            If tmp = "%" Then
                tmp = Mid(url, i + 1, 2)
                tmp = "&H" + tmp
                theC = Chr(Val(tmp))
                ToRep = Mid(url, i, 3)
                url = Replace(url, ToRep, theC)

            End If
        Next
        ParseLike = url
    End Function

    Private Function GetValuse(ByVal thecode As String, ByVal begin As String, ByVal ending As String) As String
        Dim st() As Integer
        Dim en() As Integer
        Dim Result() As String
        Dim pos As Integer
        Dim i As Integer
        pos = InStr(thecode, begin)
        While pos > 0
            ReDim Preserve st(i)
            pos += Len(begin)
            st(i) = pos
            i += 1
            pos = InStr(pos, thecode, begin)

        End While

        ReDim en(i)
        i = 0
        pos = InStr(st(i), thecode, ending)
        en(0) = pos
        For i = 1 To UBound(st)
            pos = InStr(st(i), thecode, ending)
            en(i) = pos
        Next
        ReDim Result(i)
        For i = 0 To UBound(st)
            Result(i) = ParseLike(Mid(thecode, st(i), en(i) - st(i)))
        Next
        GetValuse = Result
    End Function

    Private Function GetBetween(ByVal sSea As String, ByVal Sstart As String, ByVal sStop As String, Optional ByVal lSea As Integer = 1)
        Dim lTemp As Long
        lSea = InStr(lSea, sSea, Sstart)
        If lSea > 0 Then
            lSea += Len(Sstart)
            lTemp = InStr(lSea, sSea, sStop)
            If lTemp > lSea Then
                GetBetween = Trim(Mid(sSea, lSea, lTemp = lSea))
            End If
        End If
    End Function

    Private Function GetPage(ByVal PageUrl As String) As String
        Dim s As String = ""
        Try
            Dim request As HttpWebRequest = WebRequest.Create(PageUrl)
            Dim response As HttpWebResponse = request.GetResponse
            Using reader As StreamReader = New StreamReader(response.GetResponseStream())
                s = reader.ReadToEnd
            End Using
        Catch ex As Exception
            Debug.WriteLine("Error : " + ex.Message)
        End Try
        Return s
    End Function

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        lstv.Columns.Add("URL", CInt(lstv.Width / 3))
        lstv.Columns.Add("Type", CInt(lstv.Width / 3))
        lstv.Columns.Add("Quality", CInt(lstv.Width / 3))
        lstv.View = View.Details
    End Sub

    Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim objItem As ListViewItem
        Dim theSection As String
        Dim Url() As String
        Dim Type() As String
        Dim Qua() As String
        Dim i As Integer
        Dim page As String = GetPage(Textbox1.Text)

        theSection = GetBetween(page, "yt.playerConfig = ", ");")
        Url = GetValuse(theSection, "url=", "\")
        Type = GetValuse(theSection, "type", "\")
        Qua = GetValuse(theSection, "quality", "\")
        For i = 0 To UBound(Url) - 1
            objItem = lstv.Items.Add(Url(i))
            objItem.SubItems.Add(Type(i))
            objItem.SubItems.Add(Qua(i))
        Next
    End Sub
End Class


ช่วยแก้ให้หน่อยน่ะ ครับ
มันติดตรงนี้ ครับ

Code (VB.NET)
GetValuse = Result


และ

Code (VB.NET)
 Url = GetValuse(theSection, "url=", "\")
        Type = GetValuse(theSection, "type", "\")
        Qua = GetValuse(theSection, "quality", "\")




Tag : .NET, VB.NET







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2014-09-07 09:28:08 By : DevilH View : 1116 Reply : 10
 

 

No. 1



โพสกระทู้ ( 296 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

GetValuse = Result

GetValuse เป็น String แต่ Result เป็น Integer แบบ อาเรย์ (คิดว่านะ) ไม่ใส่ exdex ให้ Result
ลองใส่ GetValuse = Result(i)

ส่วน

Url = GetValuse(theSection, "url=", "\") Type = GetValuse(theSection, "type", "\") Qua = GetValuse(theSection, "quality", "\")

มันบักตรง Funtion GetValuse() นั่นแหละครับเลยแทนค่าไม่ได้






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-09-07 10:55:07 By : zarooman
 


 

No. 2



โพสกระทู้ ( 30 )
บทความ ( 0 )



สถานะออฟไลน์


ผมทำตามวีดีโอนี้ ครับ
http://www.youtube.com/watch?v=P0FVmyCrx64

ผมพลาดตรงไหนหรือป่าว
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-09-07 15:21:13 By : DevilH
 

 

No. 3



โพสกระทู้ ( 296 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

อย่างที่ผมบอกอะ
GetValuse = Result

Result เป็นอาเรย์ ไม่ชี้อินเด็กให้มันมันก็บักสิ ลองใส่ GetValuse = Result(0)ดู
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-09-08 11:12:05 By : zarooman
 


 

No. 4



โพสกระทู้ ( 4,436 )
บทความ ( 23 )



สถานะออฟไลน์
Facebook

http://mrbool.com/how-to-create-a-youtube-downloader-using-c/26801
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-09-08 15:27:53 By : lamaka.tor
 


 

No. 5



โพสกระทู้ ( 296 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

เท่าที่อ่านโค้ดแล้ว มันแปลกหลายอย่างครับ
อาเร

อาเร1
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-09-09 00:16:55 By : zarooman
 


 

No. 6



โพสกระทู้ ( 4,436 )
บทความ ( 23 )



สถานะออฟไลน์
Facebook

Private Function GetValuse(ByVal thecode As String, ByVal begin As String, ByVal ending As String) As String()'ต้องส่งเป็นออก Array ครับ
...
...
...

End Function
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-09-09 08:32:16 By : lamaka.tor
 


 

No. 7



โพสกระทู้ ( 4,436 )
บทความ ( 23 )



สถานะออฟไลน์
Facebook

ได้แระครับ list มาได้แต่โหลดไม่ได้ครับน่าจะติดที่ url
yt
Code (VB.NET)
Imports System.Net
Imports System.IO
Imports System.Diagnostics
Public Class Form1
    'http://www.youtube.com/watch?v=AcPxHFecum8
    'http://www.youtube.com/watch?v=n3tdS0Xrl7U&list=RDn3tdS0Xrl7U
    Private Function ParseLink(Optional ByVal url As String = "") As String
        Dim i As Integer
        For i = 1 To Len(url) - 1
            If Mid(url, i, 1) = "%" Then
                url = Replace(url, Mid(url, i, 3), Chr(Val("&H" + Mid(url, i + 1, 2))))
            End If

        Next
        ParseLink = url
    End Function
    Private Function GetValuse(ByVal thecode As String, ByVal begin As String, ByVal ending As String) As String()
        Dim st() As Integer
        Dim en() As Integer
        Dim Result() As String
        Dim pos As Integer
        Dim i As Integer
        pos = InStr(thecode, begin)
        While pos > 0
            ReDim Preserve st(i)
            pos += Len(begin)
            st(i) = pos
            i += 1
            pos = InStr(pos, thecode, begin)

        End While

        ReDim en(i)
        i = 0
        pos = InStr(st(i), thecode, ending)
        en(0) = pos
        For i = 1 To UBound(st)
            pos = InStr(st(i), thecode, ending)
            en(i) = pos
        Next
        ReDim Result(i)
        For i = 0 To UBound(st)
            Result(i) = ParseLink(Mid(thecode, st(i), en(i) - st(i)))
        Next
        GetValuse = Result
    End Function
    Private Function GetBetween(ByVal sSea As String, ByVal Sstart As String, ByVal sStop As String) As String
        Dim tmp As String = ""
        Dim result As String = ""
        If sSea.IndexOf(Sstart) > 0 Then
            tmp = sSea.Substring(sSea.IndexOf(Sstart) + Sstart.Length)
            result = tmp.Substring(1, tmp.IndexOf(sStop) + 1)
        End If
        GetBetween = result
    End Function

    Private Function GetPage(ByVal PageUrl As String) As String
        Dim s As String = ""
        Try
            Dim request As HttpWebRequest = WebRequest.Create(PageUrl)
            Dim response As HttpWebResponse = request.GetResponse
            Using reader As StreamReader = New StreamReader(response.GetResponseStream())
                s = reader.ReadToEnd
            End Using
        Catch ex As Exception
            Debug.WriteLine("Error : " + ex.Message)
        End Try
        Return s
    End Function

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        lstv.Columns.Add("URL", CInt(lstv.Width / 3))
        lstv.Columns.Add("Type", CInt(lstv.Width / 3))
        lstv.Columns.Add("Quality", CInt(lstv.Width / 3))
        lstv.View = View.Details

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim objItem As ListViewItem
        Dim theSection As String
        Dim Url() As String
        Dim Type() As String
        Dim Qua() As String
        Dim i As Integer
        Dim page As String = GetPage(TextBox1.Text)

        theSection = GetBetween(page, "ytplayer.config = ", ");</script>")
        Url = GetValuse(theSection, "url=", "\")
        Type = GetValuse(theSection, "type", "\")
        Qua = GetValuse(theSection, "quality", "\")
        On Error Resume Next
        For i = 0 To UBound(Url) - 1
            objItem = lstv.Items.Add(Url(i))
            objItem.SubItems.Add(Type(i))
            objItem.SubItems.Add(Qua(i))
        Next
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        SaveFileDialog1.FileName = vbNullString
        SaveFileDialog1.ShowDialog()
        If SaveFileDialog1.FileName <> vbNullString Then
            TextBox2.Text = lstv.SelectedItems(0).Text
            My.Computer.Network.DownloadFile(lstv.SelectedItems(0).Tag, SaveFileDialog1.FileName, _
            vbNullString, vbNullString, True, 5000, True)

        End If
    End Sub

End Class



แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-09-09 14:56:53 By : lamaka.tor
 


 

No. 8



โพสกระทู้ ( 30 )
บทความ ( 0 )



สถานะออฟไลน์


ขอบคุณ ครับ คุณ TOR_CHEMISTRY
โหลดได้แล้วครับ

แก้ตรงนี้
Code (VB.NET)
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
SaveFileDialog1.FileName = vbNullString
SaveFileDialog1.ShowDialog()
If SaveFileDialog1.FileName <> vbNullString Then
TextBox2.Text = lstv.SelectedItems(0).Text
My.Computer.Network.DownloadFile(TextBox2.Text, SaveFileDialog1.FileName, _
vbNullString, vbNullString, True, 5000, True)
End If
End Sub

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-09-09 19:00:15 By : DevilH
 


 

No. 9



โพสกระทู้ ( 4,436 )
บทความ ( 23 )



สถานะออฟไลน์
Facebook

อ๊อ ครับไอ้ผมก็ไม่ถนัดซะด้วยเรื่องโหลดหนังโป๊ อิอิ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-09-11 14:19:35 By : lamaka.tor
 


 

No. 10



โพสกระทู้ ( 30 )
บทความ ( 0 )



สถานะออฟไลน์


ผมโหลดเพลงในยูทูป ครับ !!
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-09-11 17:06:56 By : DevilH
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : อยากทำโปรแกรมโหลดวีดีโอจากยูทูบแต่ติดปัญหาที่โค้ดช่วยแก้ให้หน่อยน่ะ ครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 04
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่