Code Monkey home page Code Monkey logo

android-youtubeextractor's Introduction

Android based YouTube url extractor

These are the urls to the YouTube video or audio files, so you can stream or download them. It features an age verification circumvention and a signature deciphering method (mainly for vevo videos).

Gradle

To always build from the latest commit with all updates. Add the JitPack repository:

repositories {
    maven { url "https://jitpack.io" }
}

And the dependency:

implementation 'com.github.HaarigerHarald:android-youtubeExtractor:master-SNAPSHOT'

Usage

It's build around an AsyncTask. Called from an Activity you can write:

String youtubeLink = "http://youtube.com/watch?v=xxxx";

new YouTubeExtractor(this) {
    @Override
    public void onExtractionComplete(SparseArray<YtFile> ytFiles, VideoMeta vMeta) {
        if (ytFiles != null) {
            int itag = 22;
	    String downloadUrl = ytFiles.get(itag).getUrl();
        }
    }
}.extract(youtubeLink);

The ytFiles SparseArray is a map of available media files for one YouTube video, accessible by their itag value. For further infos about itags and their associated formats refer to: Wikipedia - YouTube Quality and formats.

Requirements

Android 4.0 (API version 14) and up for Webview Javascript execution see: js-evaluator-for-android. Not signature enciphered Videos may work on lower Android versions (untested).

Limitations

Those videos aren't working:

  • Age restricted videos
  • Everything private (private videos, bought movies, ...)
  • Unavailable in your country
  • RTMPE urls (very rare)

Modules

  • youtubeExtractor: The extractor android library.

  • sampleApp: A simple example downloader App.

  • advancedDownloader: A more sophisticated App using the mp4parser library to mux dash audio and video files together and add metadata to audio files after downloading. youtubeDownloader.apk

License

Modified BSD license see LICENSE and 3rd party licenses depending on what you need

android-youtubeextractor's People

Contributors

barisahmet avatar dn-a avatar haarigerharald avatar jideguru avatar lubo-fr avatar meoyawn avatar minos avatar razar-dev avatar xibr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-youtubeextractor's Issues

Stopped working

Hi
Since the last 12+hours the library isn't working. ytFiles always returns null.

03-07 23:38:59.902 16995-18036/com.akashpopat W/System.err: java.util.regex.PatternSyntaxException: Incorrectly nested parentheses in regexp pattern near index 13: 03-07 23:38:59.906 16995-18036/com.akashpopat W/System.err: (var |)f.sig):f.s&&k.set(=function\((.{1,3})\)\{) 03-07 23:38:59.910 16995-18036/com.akashpopat. W/System.err: ^ 03-07 23:38:59.918 16995-18036/com.akashpopat. W/System.err: at java.util.regex.Pattern.compileImpl(Native Method) 03-07 23:38:59.923 16995-18036/com.akashpopat. W/System.err: at java.util.regex.Pattern.compile(Pattern.java:411) 03-07 23:38:59.927 16995-18036/com.akashpopat. W/System.err: at java.util.regex.Pattern.<init>(Pattern.java:394) 03-07 23:38:59.932 16995-18036/com.akashpopat. W/System.err: at java.util.regex.Pattern.compile(Pattern.java:381) 03-07 23:38:59.935 16995-18036/com.akashpopat. W/System.err: at at.huber.youtubeExtractor.YouTubeUriExtractor.decipherSignature(YouTubeUriExtractor.java:402) 03-07 23:38:59.939 16995-18036/com.akashpopat. W/System.err: at at.huber.youtubeExtractor.YouTubeUriExtractor.getStreamUrls(YouTubeUriExtractor.java:320) 03-07 23:38:59.948 16995-16995/com.akashpopat. W/Ads: The webview is destroyed. Ignoring action. 03-07 23:38:59.955 16995-18036/com.akashpopat. W/System.err: at at.huber.youtubeExtractor.YouTubeUriExtractor.doInBackground(YouTubeUriExtractor.java:158) 03-07 23:38:59.960 16995-18036/com.akashpopat. W/System.err: at at.huber.youtubeExtractor.YouTubeUriExtractor.doInBackground(YouTubeUriExtractor.java:32) 03-07 23:38:59.963 16995-18036/com.akashpopat. W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:295) 03-07 23:38:59.966 16995-18036/com.akashpopat. W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237) 03-07 23:38:59.970 16995-18036/com.akashpopat. W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 03-07 23:38:59.973 16995-18036/com.akashpopat. W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 03-07 23:38:59.976 16995-18036/com.akashpopat. W/System.err: at java.lang.Thread.run(Thread.java:818)

Module App Activity not starting

I'm new in android. After runing a specific module app, it's installing in phone but activity not starting. What's wrong? Is there any hidden rule for building multiple module project?

java.io.EOFException in samsung s3

This is the complete log.

 java.io.EOFException
     at java.util.zip.GZIPInputStream.readFully(GZIPInputStream.java:206)
     at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:98)
     at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:81)
     at libcore.net.http.HttpEngine.initContentStream(HttpEngine.java:547)
     at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:850)
     at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:283)
     at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:177)
     at libcore.net.http.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:271)
     at at.huber.youtubeExtractor.YouTubeUriExtractor.getStreamUrls(YouTubeUriExtractor.java:208)
     at at.huber.youtubeExtractor.YouTubeUriExtractor.doInBackground(YouTubeUriExtractor.java:158)
     at at.huber.youtubeExtractor.YouTubeUriExtractor.doInBackground(YouTubeUriExtractor.java:32)
     at android.os.AsyncTask$2.call(AsyncTask.java:287)
     at java.util.concurrent.FutureTask.run(FutureTask.java:234)
     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
     at java.lang.Thread.run(Thread.java:841)

Didn't have this issue on other devices though.Will check on more devices.

ytFiles.get(itag).getUrl() returns null

Hi,
I just noticed there's an issue with extracting old youtube videos.

For example:
I'm trying to download Timbaland - Apologize (2009) and app crashes,

java.lang.nullpointerexception: Attempt to invoke virtual method 'java.lang.String at.huber.youtubeExtractor.YtFile.getUrl()' on a null object reference

suddenly getting error

Failed to resolve: com.github.HaarigerHarald:android-youtubeExtractor:master-SNAPSHOT

Download Location

Would it be possible to implement a way to choose the download location?

getStreamUrls() cannot get dashMpdUrl if use_cipher_signature is NOT False

Hi, HaarigerHarald,
Thanks for your implementation of youtubeExtractor. This is a very useful module for me. But here is a problem that it cannot extract correct dash MPD URL if URL is ciphered. Would you please take a look on this issue. Thank you.
source code is v1.5.0, @ rev. SHA-1: 3933c69

[my configuration]
youtubeLink = "http://youtube.com/watch?v=FD1n3SSKVcY";
parseDashManifest = true;

[result]
getStreamUrls()::YouTubeUriExtractor cannot get correct dashMpdUrl.

ytFiles still null

Hi
I opened an issue today and it was closed by you with a commit but the issue hasn't been resolved. It still gives me ytFiles is null

Thanks

Download MP3 format

Hi it is a good library to download videos from youtube. I would like to know how can I enable the mp3 format? Or do I have tu use some library to convert to mp4 to mp3? Thanks

Compatibility with latest YouTube API changes re vevo-like videos

Really appreciate this code, have used it in our app and it is truly awesome. Need a fix - URL for Vevo-like videos are no longer extractable. It would be great to have this fixed so we can extract URLs for vevo-like videos with signatures which is crucial for our work. If you can point to code snippets to accomplish that, that'd be great too.
thanks again for this great code. Fantastic work.

Content is deleted when app is unisntalled

When the app is uninstalled all the content is being removed. but if I am just updating the application (installing new apk when the app is already installed) the content is being saved. what is the problem?

Public API function to enable logging.

Hi Haariger,

Can you please add API function to enable debug mode which would print all the log statements ?

May be : public void enableLogging(boolean enable);

It would make debugging easier in downstream projects :)
If you ain't free, then I can make a pull request for that.

Regards,
Ashish Bansal

Why can't be extracted audio from YouTube URL?

I built an audio extract app using this youtubeExtractor(6/25/2016) library.
But suddenly the app can't extract audio since few days before. sometimes the app can be extracted one of few YouTube files.
Help me, please.
Thank you.

Synchronization problem in YoutubeExtractor.java

I noticed sometimes the method getStreamUrls() returned null on some videos. I wanted to know why and so I started by put some breakpoints in order to see why it returned null always on the same videos.

What I discovered is something which sounds very strange, but I want to report it (together with the solution I've found).
The problem is in line 262. Also if ytFiles.size() is not 0 the check results true and so it returns null. The point is, for the very same video, when I put a breakpoint on this line the check is always reliable; when I let it go without breakpoints it sees ytFiles.size() = 0 and so returns null.

Please check this problem with this video:
https://www.youtube.com/watch?v=b6GX0eMi8e4

I solved it by simply commenting the if statement and leaving return ytFiles. The problem seems to be a synchronization one.

//                if (ytFiles.size() == 0) {
//                    if (LOGGING)
//                        Log.d(LOG_TAG, streamMap);
//                    return null;
//                }
                return ytFiles;

EDIT:
it may be related to this problem
#2

Wrong version number in latest release

I've just downloaded https://github.com/HaarigerHarald/android-youtubeExtractor/releases/download/v1.5.0/advancedDownloader-release.apk which should be v1.5, but it claims to be v1.4:

package: name='at.huber.youtubeDownloader' versionCode='2' versionName='1.4'

Just as a note (you might wish to fix and replace it ;)

Some Video with Age Constraint cannot be Played

Hi
I found some Video which is set Age-Constraint cannot be played. For example, following video. Could you check it? I test XCDYouTube which is open source in iOS is able to be played without the constraint, hopefully helpful to your trouble-shooting.

https://www.youtube.com/watch?v=pOmTdFpIDX8
https://www.youtube.com/watch?v=cWeWR_rEy6g
https://www.youtube.com/watch?v=SkRSXFQerZs
https://www.youtube.com/watch?v=GEF1Ah8QaXw
https://www.youtube.com/watch?v=8o4Zj98FeX4

Only playable on "...sn-ipoxu..." kind of URI

Hi
In some case like slow network, I found the URI is extracted unlike the normal URI "...sn-ipoxu..." but extract out something like:
"https://r3---sn-5hnednel.googlevideo.com ..."
"https://r2---sn-vgqskn7e.googlevideo.com..."
"https://r6---sn-n4v7sn76.googlevideo.com..."
"https://r9---sn-vgqsens7.googlevideo.com..."
"https://s.ytimg.com/yts/swfbin/player-vf..."
"https://www.youtube.com/annotations_invi..."
"https://googleads.g.doubleclick.net/page..."

Any idea why it failed? Can it only play "ipoxu" URI? or it's because incomplete extraction?

video size

hello sir
how to calculate video size in different format
provide any idea

Certificate expired

When calling getStreamUrls()

com.android.org.bouncycastle.jce.exception.ExtCertPathValidatorException: Could not validate certificate: Certificate not valid until Wed Apr 01 03:00:00 GMT+03:00 2015 (compared to Thu Jan 01 02:54:25 GMT+02:00 1970)

It seems that the certificate is expired.

Can't find any links!

Has YouTube updated something from there side because now the API doesn't work and just give's no links found ?
Please fix ASAP

RTSP LINK EXPIRATION

Hello,
iam using YoutubeExtractor to create a playlist that plays in the background using "service", and i successfully did that, the problem is after couple of hours it seems that the rtsp links expire, and they are not playing anymore and i need to extract the link again and again every day.
Please advice me how to fix the issue.
Thanks.

How to get Youtube Dash URL?

Hi, HaarigerHarald,
Thanks for your implementation of youtubeExtractor.
I'm using Google ExoPlayer to play video, but I just only get Sample YouTube DASH video on Internet.
Is it possible to use your youtubeExtractor to get YouTube video DASH URL from YouTube video URL?

Some youtube link not work

My exceptional url is = https://www.youtube.com/watch?v=Y-Xlc3OY_zg

My download code is in recycleradapter.

here is my logcat

java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String at.huber.youtubeExtractor.YtFile.getUrl()' on a null object reference
                                                                        at com.bicubic.botadnews.adapter.RvHomeAdapter$NewsHolder$2.onUrisAvailable(RvHomeAdapter.java:242)
                                                                        at at.huber.youtubeExtractor.YouTubeUriExtractor.onPostExecute(YouTubeUriExtractor.java:133)
                                                                        at at.huber.youtubeExtractor.YouTubeUriExtractor.onPostExecute(YouTubeUriExtractor.java:32)
                                                                        at android.os.AsyncTask.finish(AsyncTask.java:636)
                                                                        at android.os.AsyncTask.access$500(AsyncTask.java:177)
                                                                        at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:653)
                                                                        at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                        at android.os.Looper.loop(Looper.java:135)
                                                                        at android.app.ActivityThread.main(ActivityThread.java:5268)
                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                        at java.lang.reflect.Method.invoke(Method.java:372)
                                                                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:902)
                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:697)

How to download mp3

I'm unable to locate exactly what I have to do in order to download the mp3 file. I read and noticed that you have to first download m4a and then do local conversio. But how to download m4a? Thanks in advance

Violation of YouTube's terms of service

Do your library has violated YouTube's terms of service:

C You agree not to access Content through any technology or means other than the video playback pages of the Service itself, the Embeddable Player, or other explicitly authorized means YouTube may designate.

RxJava

When will library on RxJava?

Empty SparseArray on first attempt

Hi,

I was using this library in an application and sometimes it gives empty SparseArray in first attempt but on trying again for same video, it gives all the links. I know it sounds weird but it happens a lot of times.

Do you know what could be the problem ?

Thanks!

Change the quality name

Welcome
How do I change or add quality types such as low quality, medium quality, and so on?
Is there a way to do that?
Example image in attachment

00

No Audio for videos

The url extraction for different qualities is working fine. However, when i try to play that link in browser
or in Android app in exo player, it has no sound.
e.g,
Video_Link

Faild to extrat url

it shows me only"It failed to extract. So sad" even if I used different video ids that work normally on youtube

APK version number wrong?

The .apk file of the latest release listed here on Github (v1.3.0) identifies itself as v1.1:

package: name='at.huber.youtubeDownloader' versionCode='1' versionName='1.1'

Is that intentional? A bit confusing as one might expect a newer version than already installed, but instead gets error messages from the installer ;)

Audio & video separate files

The audio download works perfectly. But when I download a video, it downloads de audio and video files separately. I would like them combined in one file.
I think I have to do something with the mp4parser but I don't know what.
What code do I have to add and where?
Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.