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

Is youtube-dl not support special characters? #2644

Closed
deepnees opened this issue Mar 27, 2014 · 1 comment
Closed

Is youtube-dl not support special characters? #2644

deepnees opened this issue Mar 27, 2014 · 1 comment

Comments

@deepnees
Copy link

@deepnees deepnees commented Mar 27, 2014

Basically i just get title of video.

$title = exec("youtube-dl ".$url." --restrict-filenames -e");

but this not give special characters or non-english characters. just "�" giving. i want to get same title and description characters.
thanks.

@phihag
Copy link
Contributor

@phihag phihag commented Mar 27, 2014

youtube-dl supports special characters just fine. However, it looks like your application does not. This program fine for me:

<?php
echo exec('youtube-dl BaW_jenozKc -e');

Because you're not dealing with any files, --restrict-filenames has no effect, so it can be safely removed.

To diagnose your problem, make sure you use the same character encoding everywhere, if possible UTF-8. You can run youtube-dl with the -v option (and with -s instead of -e) to see your system's character encoding:

$ youtube-dl -s -v BaW_jenozKc
[debug] System config: []
[debug] User config: []
[debug] Command-line args: ['-s', '-v', 'BaW_jenozKc']
[debug] Encodings: locale 'UTF-8', fs 'UTF-8', out 'UTF-8', pref: 'UTF-8'
[debug] youtube-dl version 2014.03.27.1
[debug] Git HEAD: 0dae508
[debug] Python version 2.7.6 - Linux-3.13-1-amd64-x86_64-with-debian-jessie-sid
[debug] Proxy map: {}
[youtube] Setting language
[youtube] BaW_jenozKc: Downloading webpage
[youtube] BaW_jenozKc: Downloading video info webpage
[youtube] BaW_jenozKc: Extracting video information

In the line starting with Encodings:, it should say UTF-8 everywhere. If it doesn't, there's your problem. Check your environment variables, in particular LC_ALL, which should end with .UTF-8.

Secondly, make sure that you don't mangle the title in your application. Just echoing should be fine. You can also pipe the output through htmlentities.

Thirdly, make sure that your website uses UTF-8. Its source code should contain the line

<meta charset="utf-8" />

By the way, you should really use escapeshellarg for the URL. Otherwise, you basically allow everyone who controls the $url variable to execute arbitrary code.

@phihag phihag closed this Mar 27, 2014
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.