Skip to content

Commit

Permalink
Fix sbs auth problem
Browse files Browse the repository at this point in the history
  • Loading branch information
xwz committed Oct 2, 2015
1 parent 147a0f2 commit 3967e9c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ private void hideStatusText() {
}

public void showStatusText(String text) {
showShutter(false);
statusTextView.setVisibility(View.VISIBLE);
statusTextView.setText(text);
}
Expand Down
20 changes: 18 additions & 2 deletions sbs/src/main/java/io/github/xwz/sbs/api/SBSAuthApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@ private void parseContent(String content) {
int end = content.indexOf("};", start);
if (end > pos) {
String data = content.substring(start - 1, end + 1);
Log.d(TAG, "data:" + data);
Gson gson = new Gson();
try {
PlayerParams params = gson.fromJson(data, PlayerParams.class);
Log.d(TAG, "params: " + params);
if (params != null && params.releaseUrls != null) {
if (params.releaseUrls.html != null && params.releaseUrls.html.length() > 0) {
Uri.Builder builder = Uri.parse(params.releaseUrls.html).buildUpon();
String release = params.releaseUrls.getUrl();
if (release != null && release.length() > 0) {
Uri.Builder builder = Uri.parse(release).buildUpon();
Uri url = builder.build();
loadPlayList(url);
return;
Expand Down Expand Up @@ -103,6 +105,20 @@ static class ReleaseUrl {
private String html;
private String standard;

public String getUrl() {
if (html != null) {
String url = html.toLowerCase();
if (url.startsWith("http://") || url.startsWith("https://")) {
return html;
}
if (url.startsWith("//")) {
return "http:" + html;
}
Log.d(TAG, "Invalid release URL: " + this);
}
return null;
}

public String toString() {
return progressive + " | " + html + " | " + standard;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void fetchShowList(boolean force) {
if (shouldFetch && (fetchShows == null || fetchShows.getStatus() == AsyncTask.Status.FINISHED)) {
cache().broadcastChange(CONTENT_SHOW_LIST_FETCHING);
fetchShows = new SBSApi(getContext());
fetchShows.execute();
fetchShows.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
lastFetchList = now;
}
}
Expand All @@ -47,15 +47,15 @@ public void fetchEpisode(EpisodeBaseModel episode) {
if (existing != null && existing.hasExtras() && existing.hasOtherEpisodes()) {
cache().broadcastChangeDelayed(100, CONTENT_EPISODE_DONE, episode.getHref(), null);
} else {
new SBSRelatedApi(getContext(), episode.getHref()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, episode.getHref());
new SBSRelatedApi(getContext(), episode.getHref()).execute(episode.getHref());
}
}

@Override
public void fetchAuthToken(EpisodeBaseModel episode) {
Log.d(TAG, "fetchAuthToken");
cache().broadcastChange(CONTENT_AUTH_FETCHING, episode.getHref());
new SBSAuthApi(getContext(), episode.getHref()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, episode.getHref());
new SBSAuthApi(getContext(), episode.getHref()).execute(episode.getHref());
}

@Override
Expand Down

0 comments on commit 3967e9c

Please sign in to comment.