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

Swift - How to Setup $PATH to resolve PhantomJS PATH error (OpenLoad) #22149

Closed
thealtruist opened this issue Aug 18, 2019 · 0 comments
Closed

Swift - How to Setup $PATH to resolve PhantomJS PATH error (OpenLoad) #22149

thealtruist opened this issue Aug 18, 2019 · 0 comments
Labels

Comments

@thealtruist
Copy link

@thealtruist thealtruist commented Aug 18, 2019

Checklist

  • I'm asking a question
  • I've looked through the README and FAQ for similar questions
  • I've searched the bugtracker for similar questions including closed ones

Question

WRITE QUESTION HERE

OpenLoad: How do you setup $PATH to resolve the following error?

ERROR: PhantomJS executable not found in PATH, download it from http://phantomjs.org

Context:

I read through all the posts about the error: ERROR: PhantomJS executable not found in PATH, download it from http://phantomjs.org. The solution given was to setup $PATH, but I didn't know how or where to do that. I looked up a variety of keywords on Google, but the results weren't very helpful, so I wanted to pass along the implementation that worked for me. =]

Solution:

youtube-dl looks for the phantomjs file in the location stored in the$PATH value. The $PATH value tells the command line interface where to find executable files. You need to manually set this value to the location of your phantomjs executable file.

For my Swift application, I downloaded and stored the youtube-dl, ffmpeg, and phantomjs executable files in my application's directory. To set the $PATH value to that directory, I needed to use the environment dictionary of theProcess class. The environment dictionary uses variable names as keys, and variable values as values. In Swift, it looks like this:

let environmentDictionary = ["$PATH": "/Users/davidlittlefield/path/to/phantomjs/executable/directory/"]

Then, I set the environment dictionary to the environment property of the Process class. I also had to set the currentDirectoryPath property of the Process class to the same path value that I used for $PATH. Then, I was able to successfully download titles and videos from OpenLoad! In Swift, it looks like this:

youtube-dl

Note:

Also, this code demonstrates how to run an executable file with arguments from within Swift, which was another challenge that didn't seem to have much documentation available online.

@ytdl-org ytdl-org locked as off topic and limited conversation to collaborators Aug 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.