Skip to content

Commit 6bec1a9

Browse files
shrink it down a bit and logical changes
1 parent 5423b0d commit 6bec1a9

File tree

12 files changed

+73
-142
lines changed

12 files changed

+73
-142
lines changed

.gitattributes

-22
This file was deleted.

AndroidManifest.xml

-32
Original file line numberDiff line numberDiff line change
@@ -26,38 +26,6 @@
2626
<category android:name="android.intent.category.DEFAULT" />
2727
<data android:mimeType="text/plain"/>
2828
</intent-filter>
29-
<intent-filter>
30-
<action android:name="android.intent.action.VIEW" />
31-
<category android:name="android.intent.category.DEFAULT" />
32-
<category android:name="android.intent.category.BROWSABLE" />
33-
<data android:scheme="http"
34-
android:host="youtube.com"
35-
android:pathPattern=".*/watch.*"/>
36-
<data android:scheme="http"
37-
android:host="www.youtube.com"
38-
android:pathPattern=".*/watch.*"/>
39-
<data android:scheme="http"
40-
android:host="m.youtube.com"
41-
android:pathPattern=".*/watch.*"/>
42-
<data android:scheme="http"
43-
android:host="www.m.youtube.com"
44-
android:pathPattern=".*/watch.*"/>
45-
<data android:scheme="https"
46-
android:host="youtube.com"
47-
android:pathPattern=".*/watch.*"/>
48-
<data android:scheme="https"
49-
android:host="www.youtube.com"
50-
android:pathPattern=".*/watch.*"/>
51-
<data android:scheme="https"
52-
android:host="m.youtube.com"
53-
android:pathPattern=".*/watch.*"/>
54-
<data android:scheme="https"
55-
android:host="www.m.youtube.com"
56-
android:pathPattern=".*/watch.*"/>
57-
<data android:scheme="http"
58-
android:host="youtu.be"
59-
android:pathPattern=".*/.*"/>
60-
</intent-filter>
6129

6230
</activity>
6331
</application>

LICENSE.txt renamed to LICENSE

File renamed without changes.

README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
A small android based Youtube uri extractor.
1+
A small android based YouTube uri extractor.
22
=======================================================
33

4-
These are the literal uris to the Youtube video or audio files, so you can stream or download them.
4+
These are the literal uris to the YouTube video or audio files, so you can stream or download them.
55
It features an age verification circumvention and a signature deciphering method (mainly for vevo videos).
66

77
I've made a little jar lib which should make integration super easy: [youtubeExtractor.jar](https://github.com/HaarigerHarald/android-youtubeExtractor/raw/master/bin/youtubeExtractor.jar)
@@ -17,18 +17,18 @@ It's basically build around an AsyncTask. Called from an Activity you can write
1717
public void onUrisAvailable(String videoId, String videoTitle, SparseArray<YtFile> ytFiles) {
1818
if(ytFiles!=null){
1919
int itag = 22;
20-
// itag is a Youtube format identifier, 22 for example is mp4 h264 1280x720
20+
// itag is a YouTube format identifier, 22 for example is "mp4 h264 1280x720"
2121

22-
String downloadUrl = ytFiles.get(itag).url;
22+
String downloadUrl = ytFiles.get(itag).getUrl();
2323
// TODO: Do something cool with the "downloadUrl"...
2424
}
2525
}
2626
};
2727

2828
ytEx.execute(youtubeLink);
2929

30-
The important thing is the ytFiles SparseArray. Because Youtube videos are available in multiple formats we can choose one by
31-
calling ytFiles.get(itag). One ytFile contains the uri and its appropriate meta data like: mp4 1280x720 or m4a dash aac
30+
The important thing is the ytFiles SparseArray. Because YouTube videos are available in multiple formats we can choose one by
31+
calling ytFiles.get(itag). One ytFile contains the uri and its appropriate meta data like: "mp4 1280x720" or "m4a dash aac"
3232

3333
For further infos have a look at the supplied sample YoutubeDownloader app. It uses the "Share" function in the official Youtube
3434
app to download Youtube videos. It doesn't have a launcher entry though so don't be irritated.
@@ -42,7 +42,7 @@ To try the app have a look at: [youtubeDownloader.apk](https://github.com/Haarig
4242
I'm using a useful lib for JavaScript execution, if you want to build your own lib from the sources head
4343
over to: https://github.com/evgenyneu/js-evaluator-for-android
4444

45-
Just to make it clear I'm not in any way related to Youtube!
45+
Just to make it clear I'm not in any way related to YouTube!
4646

4747

4848

bin/youtubeDownloader.apk

-209 Bytes
Binary file not shown.

bin/youtubeExtractor.jar

285 Bytes
Binary file not shown.

res/values-v11/styles.xml

-11
This file was deleted.

res/values-v14/styles.xml

-12
This file was deleted.

res/values/styles.xml

+2-15
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,7 @@
11
<resources>
22

3-
<!--
4-
Base application theme, dependent on API level. This theme is replaced
5-
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
6-
-->
7-
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
8-
<!--
9-
Theme customizations available in newer API levels can go in
10-
res/values-vXX/styles.xml, while customizations related to
11-
backward-compatibility can go here.
12-
-->
13-
</style>
14-
15-
<!-- Application theme. -->
16-
<style name="AppTheme" parent="AppBaseTheme">
17-
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
3+
<style name="AppTheme" parent="android:Theme.Holo.Light">
4+
185
</style>
196

207
</resources>

src/at/huber/sampleDownload/SampleDownloadActivity.java

+16-22
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import android.os.Build;
99
import android.os.Bundle;
1010
import android.os.Environment;
11-
import android.util.Log;
1211
import android.util.SparseArray;
1312
import android.view.View;
1413
import android.view.View.OnClickListener;
@@ -17,8 +16,8 @@
1716
import android.widget.ProgressBar;
1817
import android.widget.Toast;
1918
import at.huber.youtubeExtractor.R;
20-
import at.huber.youtubeExtractor.YtFile;
2119
import at.huber.youtubeExtractor.YouTubeUriExtractor;
20+
import at.huber.youtubeExtractor.YtFile;
2221

2322
public class SampleDownloadActivity extends Activity {
2423

@@ -29,30 +28,25 @@ public class SampleDownloadActivity extends Activity {
2928
@Override
3029
protected void onCreate(Bundle savedInstanceState) {
3130
super.onCreate(savedInstanceState);
31+
3232
setContentView(R.layout.activity_sample_download);
3333
mainLayout=(LinearLayout)findViewById(R.id.main_layout);
3434
mainProgressBar=(ProgressBar)findViewById(R.id.prgrBar);
3535
activityContext=this;
3636

3737
//Check how it was started and if we can get the youtubelink somehow
38-
if (savedInstanceState == null && ((Intent.ACTION_SEND.equals(getIntent().getAction()) && getIntent().getType() != null) ||
39-
Intent.ACTION_VIEW.equals(getIntent().getAction()))) {
40-
String youtubeLink=null;
41-
if(Intent.ACTION_SEND.equals(getIntent().getAction()) && "text/plain".equals(getIntent().getType())){
42-
youtubeLink=getIntent().getStringExtra(Intent.EXTRA_TEXT);
43-
}else if(Intent.ACTION_VIEW.equals(getIntent().getAction())){
44-
youtubeLink=getIntent().getDataString();
45-
}
38+
if (savedInstanceState == null && Intent.ACTION_SEND.equals(getIntent().getAction())
39+
&& getIntent().getType() != null && "text/plain".equals(getIntent().getType())){
4640

47-
if (youtubeLink != null && (youtubeLink.contains("http://youtu.be/") || youtubeLink
48-
.contains("youtube.com/watch?v="))){
49-
//We have a valid link such as: http://youtu.be/xxxx or http://youtube.com/watch?v=xxxx
41+
String youtubeLink=getIntent().getStringExtra(Intent.EXTRA_TEXT);
42+
43+
if (youtubeLink != null && (youtubeLink.contains("http://youtu.be/") ||
44+
youtubeLink.contains("youtube.com/watch?v="))){
45+
// We have a valid link such as: http://youtu.be/xxxx or
46+
// http://youtube.com/watch?v=xxxx
5047
getYoutubeDownloadUrl(youtubeLink);
5148
}else{
5249
Toast.makeText(this, R.string.error_no_yt_link, Toast.LENGTH_LONG).show();
53-
if (youtubeLink != null){
54-
Log.d("Link:", youtubeLink);
55-
}
5650
finish();
5751
}
5852
}else{
@@ -79,9 +73,9 @@ public void onUrisAvailable(String videoId, String videoTitle, SparseArray<YtFil
7973
YtFile ytFile=ytFiles.get(itag);
8074

8175
//Ignore the google proprietary webm format
82-
if(!ytFile.meta.ext.equalsIgnoreCase("webm")){
76+
if(!ytFile.getMeta().getExt().equalsIgnoreCase("webm")){
8377
//Just add videos in a decent format => height -1 = audio
84-
if(ytFile.meta.height>0 && ytFile.meta.height<360){
78+
if(ytFile.getMeta().getHeight()>0 && ytFile.getMeta().getHeight()<360){
8579
continue;
8680
}
8781
addButtonToMainLayout(videoTitle, ytFile);
@@ -97,19 +91,19 @@ public void onUrisAvailable(String videoId, String videoTitle, SparseArray<YtFil
9791
private void addButtonToMainLayout(final String videoTitle, final YtFile ytfile){
9892
//Lets display some buttons to let the user choose the format he wants to download
9993
Button btn=new Button(activityContext);
100-
btn.setText(ytfile.meta.info);
94+
btn.setText(ytfile.getMeta().getInfo());
10195
btn.setOnClickListener(new OnClickListener() {
10296

10397
@Override
10498
public void onClick(View v) {
10599
String filename;
106100
if (videoTitle.length() > 55){
107-
filename=videoTitle.substring(0, 55) + "." + ytfile.meta.ext;
101+
filename=videoTitle.substring(0, 55) + "." + ytfile.getMeta().getExt();
108102
}else{
109-
filename=videoTitle + "." + ytfile.meta.ext;
103+
filename=videoTitle + "." + ytfile.getMeta().getExt();
110104
}
111105
filename=filename.replaceAll("\\\\|>|<|\"|\\||\\*|\\?|%|:", "");
112-
downloadFromUrl(ytfile.url, videoTitle, filename);
106+
downloadFromUrl(ytfile.getUrl(), videoTitle, filename);
113107
finish();
114108
}
115109
});

src/at/huber/youtubeExtractor/Meta.java

+31-15
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,43 @@
22

33
public class Meta {
44

5-
/**
5+
int itag;
6+
String ext;
7+
String info;
8+
int height;
9+
10+
Meta(int itag, String ext, String info, int height) {
11+
this.itag=itag;
12+
this.info = info;
13+
this.ext = ext;
14+
this.height=height;
15+
}
16+
17+
/**
618
* An identifier used by youtube for different formats.
719
*/
8-
public int itag;
9-
/**
10-
* The file extension and conainer format.
20+
public int getItag(){
21+
return itag;
22+
}
23+
24+
/**
25+
* The file extension and conainer format like "mp4"
1126
*/
12-
public String ext;
27+
public String getExt() {
28+
return ext;
29+
}
1330
/**
14-
* General info about the meta data like dash 1280x720 or dash audio aac
31+
* General info about the meta data like "dash 1280x720" or "dash audio aac"
1532
*/
16-
public String info;
33+
public String getInfo() {
34+
return info;
35+
}
36+
1737
/**
1838
* The height of the video stream or -1 for audio files.
1939
*/
20-
public int height;
21-
22-
Meta(int itag, String ext, String info, int height) {
23-
this.itag=itag;
24-
this.info = info;
25-
this.ext = ext;
26-
this.height=height;
27-
}
40+
public int getHeight() {
41+
return height;
42+
}
43+
2844
}

src/at/huber/youtubeExtractor/YtFile.java

+17-6
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,25 @@
22

33
public class YtFile {
44

5-
public Meta meta;
6-
/**
7-
* The url to download the file.
8-
*/
9-
public String url = "";
5+
Meta meta;
6+
String url = "";
107

118
YtFile(Meta meta, String url) {
129
this.meta=meta;
1310
this.url = url;
1411
}
15-
}
12+
13+
/**
14+
* The url to download the file.
15+
*/
16+
public String getUrl(){
17+
return url;
18+
}
19+
20+
/**
21+
* Meta data for the specific file.
22+
*/
23+
public Meta getMeta(){
24+
return meta;
25+
}
26+
}

0 commit comments

Comments
 (0)