السلام عليكم ورحمة الله و بركاته
الكود الوحيد اللي عمل معاي هو التالي:
كود :
from pytubefix import YouTube
from pytubefix.cli import on_progress
url = input("put url here: ")
yt = YouTube(url, on_progress_callback = on_progress)
print(yt.title)
ys = yt.streams.get_highest_resolution()
directory_path = r"Path_To_your_Folder"
ys.download(directory_path)
لا تنسى تعدل على مكان حفظ الفيديو
من لديه فكرة عن كيفية التعامل مع البايثون لا اريد الاحتراف فيه و انما فقط اريد رابط فيديو مباشر يطبعه وانا اتعامل معه عبر اي برنامج اخر.
وشكر الله لكم جميعا
الجواب سهل وهو ys.url
الباقي اظنه بسيط لكن كيف!!!
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
كل شي سهل الان:
اكواد البايثون:
كود :
from pytubefix import YouTube
import sys
def get_direct_video_url(youtube_url):
try:
yt = YouTube(youtube_url)
# You can choose a specific stream based on resolution, format, etc.
# For example, to get the highest resolution progressive stream:
stream = yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().first()
if stream:
return stream.url
else:
return "No suitable stream found."
except Exception as e:
return f"Error: {e}"
if __name__ == "__main__":
if len(sys.argv) > 1:
youtube_url = sys.argv[1]
direct_url = get_direct_video_url(youtube_url)
print(direct_url)
else:
print("Usage: python get_video_url.py <youtube_url>")
اكواد الvb.net:
كود :
Imports System.Diagnostics
Imports System.IO
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim youtubeUrl As String = TextBox1.Text ' Get YouTube URL from a TextBox
Dim pythonScriptPath As String = "C:\Path\To\your\get_video_url.py" ' Adjust this path
Dim pythonExecutablePath As String = "C:\Path\To\your\python.exe" ' Adjust this path
Dim startInfo As New ProcessStartInfo()
startInfo.FileName = pythonExecutablePath
startInfo.Arguments = $"{pythonScriptPath} ""{youtubeUrl}""" ' Pass the YouTube URL as an argument
startInfo.UseShellExecute = False
startInfo.RedirectStandardOutput = True
startInfo.CreateNoWindow = True
Using process As Process = Process.Start(startInfo)
Using reader As StreamReader = process.StandardOutput
Dim directVideoUrl As String = reader.ReadToEnd().Trim()
TextBox2.Text = directVideoUrl ' Display the direct URL in another TextBox
End Using
End Using
End Sub
End Class
الان لديك الرابط المباشر تستطيع تحميله عن طريق واجهة vb.net
و السلام عليكم ورحمة الله و بركاته
على فكرة لو حولت ملف البايثون الى exe اجعله هو الهدف كـ Filename .
لو اظن احد مهتم كان رفعت مثال بسيط لكني اظن لا احد يجهل هذه المعلومة سواي
