Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use IronPython.Net In C# for Youtube-dl any Sample Code? #18703

Closed
abmspirit opened this issue Dec 31, 2018 · 3 comments
Closed

How to use IronPython.Net In C# for Youtube-dl any Sample Code? #18703

abmspirit opened this issue Dec 31, 2018 · 3 comments

Comments

@abmspirit
Copy link

@abmspirit abmspirit commented Dec 31, 2018

My Code Is always retunring Null

    ScriptRuntimeSetup setup = Python.CreateRuntimeSetup(null);
    ScriptRuntime runtime = new ScriptRuntime(setup);
    ScriptEngine engine = Python.GetEngine(runtime);
    var searchPaths = engine.GetSearchPaths();     
    searchPaths.Add(Server.MapPath("~/Lib"));
    searchPaths.Add(Server.MapPath("~/youtube-dl"));
    engine.SetSearchPaths(searchPaths);
     ScriptSource source = engine.CreateScriptSourceFromFile(Server.MapPath("~/youtube-dl/__main__.py"));
    ScriptScope scope = engine.CreateScope();
    List<String> argv = new List<String>();
    //Do some stuff and fill argv
    argv.Add("--dump-json");
    argv.Add("https://www.youtube.com/watch?v=sxLnf-B7-3w");
    engine.GetSysModule().SetVariable("argv", argv);
    dynamic  x=source.Execute(scope);
@dstftw
Copy link
Collaborator

@dstftw dstftw commented Dec 31, 2018

Most likely you are doing something wrong as it works fine from console:

> C:\Bin\IronPython\IronPython-2.7.7\ipy64.exe .\youtube_dl\__main__.py -v sxLnf-B7-3w
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-v', 'sxLnf-B7-3w']
[debug] Encodings: locale cp1251, fs mbcs, out cp866, pref cp1251
[debug] youtube-dl version 2018.12.17
[debug] Git HEAD: c2dd2dc
[debug] Python version 2.7.7 (IronPython) - cli-10-AMD64-Intel64_Family_6_Model_42_Stepping_7,_GenuineIntel-64bit
[debug] exe versions: ffmpeg N-85653-gb4330a0, ffprobe N-85653-gb4330a0, phantomjs 2.1.1, rtmpdump 2.4
[debug] Proxy map: {}
[youtube] sxLnf-B7-3w: Downloading webpage
[youtube] sxLnf-B7-3w: Downloading video info webpage
...
[download] Destination: Fashion full movie with subtitles-sxLnf-B7-3w.f136.mp4
[download]  13.0% of 1.20GiB at  3.96MiB/s ETA 04:30
ERROR: Interrupted by user
@dstftw dstftw closed this Dec 31, 2018
@abmspirit
Copy link
Author

@abmspirit abmspirit commented Jan 1, 2019

Most likely you are doing something wrong as it works fine from console:

> C:\Bin\IronPython\IronPython-2.7.7\ipy64.exe .\youtube_dl\__main__.py -v sxLnf-B7-3w
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-v', 'sxLnf-B7-3w']
[debug] Encodings: locale cp1251, fs mbcs, out cp866, pref cp1251
[debug] youtube-dl version 2018.12.17
[debug] Git HEAD: c2dd2dc
[debug] Python version 2.7.7 (IronPython) - cli-10-AMD64-Intel64_Family_6_Model_42_Stepping_7,_GenuineIntel-64bit
[debug] exe versions: ffmpeg N-85653-gb4330a0, ffprobe N-85653-gb4330a0, phantomjs 2.1.1, rtmpdump 2.4
[debug] Proxy map: {}
[youtube] sxLnf-B7-3w: Downloading webpage
[youtube] sxLnf-B7-3w: Downloading video info webpage
...
[download] Destination: Fashion full movie with subtitles-sxLnf-B7-3w.f136.mp4
[download]  13.0% of 1.20GiB at  3.96MiB/s ETA 04:30
ERROR: Interrupted by user

The process you have mentioned ,i have to load the process into memory.I used this method with winpython and youtube-dl zipped version and it worked.
But when new request comes to server new instance of python is created in memory and it consumes nearly 20 mb untill it finish the job,So for 10000 request IIS server will be blown away.So i am trying to use this without loading interpreter in memory.I think ironpython.net is known for this.

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Jan 1, 2019

I'm not telling you must run it as process. I just mentioned this to show that youtube-dl is adapted to work with IronPython and does actually work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.