Skip to content

Commit 3875689

Browse files
committed
Version 1.2
New provider.
1 parent 33c014f commit 3875689

File tree

8 files changed

+35
-33
lines changed

8 files changed

+35
-33
lines changed

apk/YoutubeDownloader.apk

-125 KB
Binary file not shown.

app/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ android {
77
minSdkVersion 15
88
targetSdkVersion 27
99
versionCode 1
10-
versionName "1.1"
10+
versionName "1.2"
1111
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1212
}
1313
buildTypes {

app/src/main/java/com/dbeqiraj/youtubedownloader/api/VideoApiService.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
import io.reactivex.Observable;
66
import retrofit2.http.GET;
77
import retrofit2.http.Path;
8+
import retrofit2.http.Query;
89

910
/**
1011
* Created by d.beqiraj on 5/19/2018.
1112
*/
1213

1314
public interface VideoApiService {
1415

15-
@GET("/@api/json/mp3/{vidID}")
16-
Observable<Video> getVideo(@Path("vidID") String vidID);
16+
@GET("/ytconverter/convert.php")
17+
Observable<Video> getVideo(@Query("youtubelink") String youtubelink);
1718
}

app/src/main/java/com/dbeqiraj/youtubedownloader/application/App.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ private void initializeFresco() {
3333
private void initializeApplicationComponent() {
3434
mApplicationComponent = DaggerApplicationComponent
3535
.builder()
36-
.applicationModule(new ApplicationModule(this, "https://baixaryoutube.net"))
36+
.applicationModule(new ApplicationModule(this, "http://michaelbelgium.me"))
3737
.build();
3838
}
3939

app/src/main/java/com/dbeqiraj/youtubedownloader/modules/download/DownloadActivity.java

+2-8
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,7 @@ private void getVideo() {
9494
title = StringUtils.substringBetween(extras.getString(Intent.EXTRA_SUBJECT), "Watch \"", "\" on YouTube");
9595
String link = extras.getString(Intent.EXTRA_TEXT);
9696
if (link != null) {
97-
int index = link.lastIndexOf("/") + 1;
98-
if ( index > -1 ) {
99-
String id = link.substring(index);
100-
videoPresenter.getVideo(id);
101-
} else {
102-
onShowToast(getString(R.string.invalid_link));
103-
}
97+
videoPresenter.getVideo(link);
10498
} else {
10599
onShowToast(getString(R.string.invalid_link));
106100
}
@@ -117,7 +111,7 @@ public void onVideoInfoDownloaded(Video video) {
117111
.replaceAll("\"", "_")
118112
.replaceAll("&amp;", "&");
119113

120-
video.setVidTitle(title);
114+
video.setTitle(title);
121115

122116
Intent intent = new Intent(this, DownloadService.class);
123117
intent.putExtra("video", video);

app/src/main/java/com/dbeqiraj/youtubedownloader/modules/download/service/DownloadService.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ protected void onHandleIntent(@Nullable Intent intent) {
7878

7979
notificationBuilder = new NotificationCompat.Builder(this, "")
8080
.setSmallIcon(R.drawable.ic_download)
81-
.setContentTitle(video.getVidTitle())
81+
.setContentTitle(video.getTitle())
8282
.setContentText(getString(R.string.download_started))
8383
.setAutoCancel(true);
8484

@@ -90,7 +90,7 @@ protected void onHandleIntent(@Nullable Intent intent) {
9090

9191
notificationManager.notify(0, notificationBuilder.build());
9292

93-
initDownload(video.getVidInfo().get("0").getDloadUrl());
93+
initDownload(video.getFile());
9494

9595
}
9696

@@ -109,7 +109,7 @@ private boolean writeResponseBodyToDisk(ResponseBody body) {
109109
}
110110

111111
if ( root.exists() ) {
112-
File file = new File(rootDir + File.separator + video.getVidTitle() + ".mp3");
112+
File file = new File(rootDir + File.separator + video.getTitle() + ".mp3");
113113

114114
InputStream inputStream = null;
115115
OutputStream outputStream = null;
@@ -153,7 +153,7 @@ private boolean writeResponseBodyToDisk(ResponseBody body) {
153153
outputStream.flush();
154154

155155
// Music file
156-
Utils.isMusic(getApplicationContext(), file, video.getVidTitle());
156+
Utils.isMusic(getApplicationContext(), file, video.getTitle());
157157

158158
return true;
159159
} catch (IOException e) {

app/src/main/java/com/dbeqiraj/youtubedownloader/mvp/model/Video.java

+22-15
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,40 @@
99

1010
public class Video implements Serializable {
1111

12-
private HashMap<String, VidInfo> vidInfo;
13-
private String vidTitle;
14-
private String vidID;
12+
private Boolean error;
13+
private String title;
14+
private Long duration;
15+
private String file;
1516

16-
public HashMap<String, VidInfo> getVidInfo() {
17-
return vidInfo;
17+
public Boolean getError() {
18+
return error;
1819
}
1920

20-
public void setVidInfo(HashMap<String, VidInfo> vidInfo) {
21-
this.vidInfo = vidInfo;
21+
public void setError(Boolean error) {
22+
this.error = error;
2223
}
2324

24-
public String getVidTitle() {
25-
return vidTitle;
25+
public String getTitle() {
26+
return title;
2627
}
2728

28-
public void setVidTitle(String vidTitle) {
29-
this.vidTitle = vidTitle;
29+
public void setTitle(String title) {
30+
this.title = title;
3031
}
3132

32-
public String getVidID() {
33-
return vidID;
33+
public Long getDuration() {
34+
return duration;
3435
}
3536

36-
public void setVidID(String vidID) {
37-
this.vidID = vidID;
37+
public void setDuration(Long duration) {
38+
this.duration = duration;
3839
}
3940

41+
public String getFile() {
42+
return file;
43+
}
4044

45+
public void setFile(String file) {
46+
this.file = file;
47+
}
4148
}

app/src/main/java/com/dbeqiraj/youtubedownloader/mvp/presenter/VideoPresenter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ public class VideoPresenter extends BasePresenter<DownloadView> implements Obser
2828
public VideoPresenter() {
2929
}
3030

31-
public void getVideo(String vidID) {
31+
public void getVideo(String youtubelink) {
3232
getView().onStartVidInfDownload();
33-
Observable<Video> cakesResponseObservable = mApiService.getVideo(vidID);
33+
Observable<Video> cakesResponseObservable = mApiService.getVideo(youtubelink);
3434
subscribe(cakesResponseObservable, this);
3535
}
3636

0 commit comments

Comments
 (0)