1010import org .schabi .newpipe .database .stream .model .StreamEntity ;
1111import org .schabi .newpipe .extractor .stream .StreamType ;
1212
13+ import java .util .List ;
1314import java .util .stream .Stream ;
1415
1516public class LocalPlaylistFragmentTest {
@@ -30,6 +31,42 @@ public void exportAsYouTubeTempPlaylist() {
3031 Assert .assertEquals ("http://www.youtube.com/watch_videos?video_ids=1,2,3" , url );
3132 }
3233
34+ @ Test
35+ public void exportMoreThan50Items () {
36+ /*
37+ * Playlist has more than 50 items => take the last 50
38+ * (YouTube limitation)
39+ */
40+
41+ final List <Integer > ids = List .of (
42+
43+ -1 , 0 ,
44+ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ,
45+ 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 ,
46+ 21 , 22 , 23 , 24 , 25 , 26 , 27 , 28 , 29 , 30 ,
47+ 31 , 32 , 33 , 34 , 35 , 36 , 37 , 38 , 39 , 40 ,
48+ 41 , 42 , 43 , 44 , 45 , 46 , 47 , 48 , 49 , 50
49+ );
50+
51+ final Stream <StreamEntity > entityStream = ids .stream ()
52+ .map (id -> "https://www.youtube.com/watch?v=" + id )
53+ .map (LocalPlaylistFragmentTest ::newStreamEntity );
54+
55+ final String url = LocalPlaylistFragment .export (YOUTUBE_TEMP_PLAYLIST , entityStream , null );
56+
57+ Assert .assertEquals (
58+
59+ "http://www.youtube.com/watch_videos?video_ids="
60+ + "1,2,3,4,5,6,7,8,9,10,"
61+ + "11,12,13,14,15,16,17,18,19,20,"
62+ + "21,22,23,24,25,26,27,28,29,30,"
63+ + "31,32,33,34,35,36,37,38,39,40,"
64+ + "41,42,43,44,45,46,47,48,49,50" ,
65+
66+ url
67+ );
68+ }
69+
3370 @ Test
3471 public void exportJustUrls () {
3572
0 commit comments