Skip to content

Commit

Permalink
release: '002.00.49-16API'
Browse files Browse the repository at this point in the history
* POST data sent in requests to "/play" and "/queue" API endpoints:
  - multiple lines can repeat the following key to declare more than one value:
    * content-location
  • Loading branch information
warren-bank committed Oct 27, 2022
1 parent 117e5ea commit 7ac129c
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 4 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,13 @@ __extended APIs:__
--data-binary "Content-Location: ${video_url_3}\nCaption-Location: ${caption_url_3}\nReferer: ${videos_page}\nStart-Position: 30" \
"http://${airplay_ip}/queue"
```
* play video #1 and add videos #2 and #3 to end of queue (set 'Referer' request header):
```bash
curl --silent -X POST \
-H "Content-Type: text/parameters" \
--data-binary "Content-Location: ${video_url_1}\nContent-Location: ${video_url_2}\nContent-Location: ${video_url_3}\nReferer: ${videos_page}" \
"http://${airplay_ip}/play"
```
* play DRM video #1 (seek to 10 seconds, end playback at 30 seconds):
```bash
curl --silent -X POST \
Expand Down Expand Up @@ -449,6 +456,7 @@ __extended APIs:__
- keys are not case sensitive
- recognized keys include:
* _content-location_
- use key on multiple lines to declare more than one value
* _caption-location_
* _referer_
* _req-header_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,9 @@ public interface Video_Source_Map {
public static final String PLAYLIST_URLS = "playlist-urls";
}

public interface Delimiter {
public static final String DEFAULT = "\n";
public static final String PLAYLIST_URLS = "{{<<|^|>>}}";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ else if (

HashMap<String, ArrayList<String>> map = StringUtils.parseRequestBody_allowDuplicateKeys(requestBody, /* normalize_lowercase_keys= */ true);

playUrl = (String) StringUtils.getLastListItem((ArrayList<String>) map.get("content-location"));
playUrl = (String) StringUtils.serializeURLs( (ArrayList<String>) map.get("content-location"));
textUrl = (String) StringUtils.getLastListItem((ArrayList<String>) map.get("caption-location"));
referUrl = (String) StringUtils.getLastListItem((ArrayList<String>) map.get("referer"));
useCache = (String) StringUtils.getLastListItem((ArrayList<String>) map.get("use-cache"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.github.warren_bank.exoplayer_airplay_receiver.service.playlist_extractors.FileM3uPlaylistExtractor;
import com.github.warren_bank.exoplayer_airplay_receiver.service.playlist_extractors.HttpHtmlPlaylistExtractor;
import com.github.warren_bank.exoplayer_airplay_receiver.service.playlist_extractors.HttpM3uPlaylistExtractor;
import com.github.warren_bank.exoplayer_airplay_receiver.service.playlist_extractors.SerializedPlaylistExtractor;
import com.github.warren_bank.exoplayer_airplay_receiver.ui.ImageViewerActivity;
import com.github.warren_bank.exoplayer_airplay_receiver.ui.RuntimePermissionsRequestActivity;
import com.github.warren_bank.exoplayer_airplay_receiver.ui.VideoPlayerActivity;
Expand Down Expand Up @@ -44,6 +45,7 @@ final class MyMessageHandler extends Handler {
private ArrayList<Message> externalStorageMessages;

private HandlerThread networkingHandlerThread;
private SerializedPlaylistExtractor serializedExtractor;
private HttpM3uPlaylistExtractor httpM3uExtractor;
private HttpHtmlPlaylistExtractor httpHtmlExtractor;
private ContentProviderM3uPlaylistExtractor contentM3uExtractor;
Expand All @@ -62,6 +64,7 @@ public MyMessageHandler(Looper looper, NetworkingService service) {
networkingHandlerThread = new HandlerThread("MyNetworkingThread");
networkingHandlerThread.start();

serializedExtractor = new SerializedPlaylistExtractor();
httpM3uExtractor = new HttpM3uPlaylistExtractor();
httpHtmlExtractor = new HttpHtmlPlaylistExtractor();
contentM3uExtractor = new ContentProviderM3uPlaylistExtractor(service.getApplicationContext());
Expand Down Expand Up @@ -609,6 +612,9 @@ private ArrayList<String> extractPlaylists(String uri, ArrayList<String> playlis

ArrayList<String> matches = null;

if (matches == null)
matches = serializedExtractor.expandPlaylist(uri);

if (matches == null)
matches = httpM3uExtractor.expandPlaylist(uri); //8-bit ascii

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.github.warren_bank.exoplayer_airplay_receiver.service.playlist_extractors;

import com.github.warren_bank.exoplayer_airplay_receiver.utils.StringUtils;

import java.util.ArrayList;

public class SerializedPlaylistExtractor {
public ArrayList<String> expandPlaylist(String strUrl) {
ArrayList<String> matches = StringUtils.deserializeURLs(strUrl);

return ((matches == null) || (matches.size() < 2))
? null
: matches;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.github.warren_bank.exoplayer_airplay_receiver.utils;

import com.github.warren_bank.exoplayer_airplay_receiver.constant.Constant;

import android.os.Bundle;
import android.text.TextUtils;

Expand All @@ -8,9 +10,11 @@
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.TreeMap;
import java.util.regex.Pattern;

public class StringUtils {

Expand Down Expand Up @@ -128,7 +132,7 @@ public static HashMap<String, String> parseDuplicateKeyValues(List<String> list)
public static HashMap<String, String> parseDuplicateKeyValues(List<String> list, boolean normalize_lowercase_keys) {
if ((list == null) || list.isEmpty()) return null;

String requestBody = TextUtils.join("\n", list);
String requestBody = StringUtils.convertListToString(list, "\n");

return StringUtils.parseRequestBody(requestBody, normalize_lowercase_keys);
}
Expand Down Expand Up @@ -168,6 +172,14 @@ public static String encodeURL(URL url) {
}
}

public static String serializeURLs(ArrayList<String> list) {
return StringUtils.convertArrayListToString(list, Constant.Delimiter.PLAYLIST_URLS);
}

public static ArrayList<String> deserializeURLs(String text) {
return StringUtils.convertStringToArrayList(text, Pattern.quote(Constant.Delimiter.PLAYLIST_URLS));
}

public static String toString(HashMap<String, String> map) {
if ((map == null) || map.isEmpty()) return null;

Expand Down Expand Up @@ -294,6 +306,39 @@ public static ArrayList<String> convertHashMapToArrayList(HashMap<String, String

// ===================================

public static String convertArrayListToString(ArrayList<String> list, String delimiter_token) {
return StringUtils.convertListToString((List<String>) list, delimiter_token);
}

public static String convertListToString(List<String> list, String delimiter_token) {
if ((list == null) || list.isEmpty()) return null;

if (delimiter_token == null)
delimiter_token = Constant.Delimiter.DEFAULT;

return TextUtils.join(delimiter_token, list);
}

public static ArrayList<String> convertStringToArrayList(String text, String delimiter_token) {
List<String> list = StringUtils.convertStringToList(text, delimiter_token);

return new ArrayList<String>(list);
}

public static List<String> convertStringToList(String text, String delimiter_token) {
if (TextUtils.isEmpty(text)) return Collections.emptyList();

if (delimiter_token == null)
delimiter_token = Pattern.quote(Constant.Delimiter.DEFAULT);

String[] strArray = TextUtils.split(text, delimiter_token);
List<String> list = (List<String>) Arrays.asList(strArray);

return list;
}

// ===================================

public static String repeatString(String value, int count) {
return ((value != null) && (count > 0))
? (new String(new char[count])).replace("\0", value)
Expand Down
4 changes: 2 additions & 2 deletions android-studio-project/constants.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
project.ext {
releaseVersionCode = Integer.parseInt("002004816", 10) //Integer.MAX_VALUE == 2147483647
releaseVersion = '002.00.48-16API'
releaseVersionCode = Integer.parseInt("002004916", 10) //Integer.MAX_VALUE == 2147483647
releaseVersion = '002.00.49-16API'
javaVersion = JavaVersion.VERSION_1_8
minSdkVersion = 16
targetSdkVersion = 29
Expand Down

0 comments on commit 7ac129c

Please sign in to comment.