Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!--
- ######################################################################
- WARNING!
- IGNORING THE FOLLOWING TEMPLATE WILL RESULT IN ISSUE CLOSED AS INCOMPLETE
- ######################################################################
- -->
- ## Checklist
- <!--
- Carefully read and work through this check list in order to prevent the most common mistakes and misuse of youtube-dl:
- - Look through the README (http://yt-dl.org/readme) and FAQ (http://yt-dl.org/faq) for similar questions
- - Search the bugtracker for similar questions: http://yt-dl.org/search-issues
- - Finally, put x into all relevant boxes (like this [x])
- -->
- - [x] I'm asking a question
- - [x] I've looked through the README and FAQ for similar questions
- - [x] I've searched the bugtracker for similar questions including closed ones
- ## Question
- <!--
- Ask your question in an arbitrary form. Please make sure it's worded well enough to be understood, see https://github.com/ytdl-org/youtube-dl#is-the-description-of-the-issue-itself-sufficient.
- -->
- 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](https://github.com/ytdl-org/youtube-dl#what-is-this-binary-file-where-has-the-code-gone), [ffmpeg](https://github.com/kribblo/node-ffmpeg-installer#readme), and [phantomjs](http://phantomjs.org) executable files in my application's directory. To set the `$PATH` value to that directory, I needed to use the **environment dictionary** of the`Process` 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](https://user-images.githubusercontent.com/30560737/63229941-ff21e500-c1ba-11e9-814a-577a2268e82e.png)
- ## 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.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement