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

running youtube-dl on android (samsung galaxy s3 phone) #1654

Closed
nemesisb12 opened this issue Oct 26, 2013 · 2 comments
Closed

running youtube-dl on android (samsung galaxy s3 phone) #1654

nemesisb12 opened this issue Oct 26, 2013 · 2 comments

Comments

@nemesisb12
Copy link

@nemesisb12 nemesisb12 commented Oct 26, 2013

I have tried to run the youtube-dl.py script on android following the procedure described in #967 but not all the steps are indicated.

I couldn't figure out how to run the script using the direct method: "python youtube-dl.py" so I tried to create a top-level file that calls the script and it looks like it wants to run, but I get the error:

"SyntaxError: Non-ASCII character '\xeb' in file /storage/sdcard0/sl4a/scripts/youtube-dl.py on line 3, but no encoding declared"

I then added a line to define the encoding as utf-8 in my top level script and then into youtube-dl.py as the second line, but that gives another error, probably because youtube-dl is actually a binary file of some sort. The encoding line I added is

-- coding: utf-8 --

My top level file looks like this (I renamed youtube-dl.py as youtube_dl.py because python can't import modules that contain dashes in the name):
.
.

-- coding: utf-8 --

import android
import os, sys
import youtube_dl

droid = android.Android()

os.system("/storage/sdcard0/data/mydata/youtube-dl.py sfR_HWMzgyc")

youtube-dl.main()

youtube_dl.main("sfR_HWMzgyc")

execfile('/storage/sdcard0/sl4a/scripts/youtube-dl.py sfR_HWMzgyc')

.
.

I'm a little stuck right now since I don't know what to try next.

Could you provide the exact steps that you used to generate that screenshot which shows that youtube-dl was able to run all the way through? I'm running sl4a 2.6 like you.

Thanks in advance.

@phihag
Copy link
Contributor

@phihag phihag commented Oct 28, 2013

What is the output of python --version on your system? The SyntaxError normally indicates an outdated Python.

Also note that in your second approach, you should rename youtube-dl to something other than youtube_dl.py - that's just confusing. Instead, you can rename it to ytdl and then use a script like

import sys
sys.path.append('/path/to/replace/this/ytdl')
import youtube_dl
youtube_dl.main(['sfR_HWMzgyc'])

If you want to follow up on my post with the screenshot (which used your first method, but with a current Python), please just comment there. Otherwise, it gets too confusing to track the problems over multiple issues. Additionally, people searching for android can then benefit from your experience. Thanks!

@phihag phihag closed this Oct 28, 2013
@YECAPP
Copy link

@YECAPP YECAPP commented Feb 12, 2017

Final run ok for me, this is the code that running right

import sys,os
sys.path.append('/path/to/replace/this/ytdl')
import youtube_dl
os.chdir(r'/sdcard/Download')
youtube_dl.main(['sfR_HWMzgyc'])

Add os library to change directory if denied write permissions

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
3 participants
You can’t perform that action at this time.