@@ -50,6 +50,7 @@ public class VideoCollectionTemplate implements TemplateInterface {
5050 private static final String YOUTUBE_SHORT = "youtu.be" ;
5151 private static final String DAILYMOTION = "dailymotion" ;
5252 private static final String VIMEO = "vimeo" ;
53+ private static final String METACAFE = "metacafe" ;
5354 transient private VideoCollectionAdapter adapter ;
5455 private ArrayList <VideoModel > videoData ;
5556 transient private ProgressDialog progress ;
@@ -71,7 +72,7 @@ private static boolean validated(Context context, EditText link) {
7172 if ("" .equals (linkText )) {
7273 link .setError (context .getString (R .string .video_collection_template_link_hint ));
7374 return false ;
74- } else if (!(linkText .contains (YOUTUBE + ".com" ) || linkText .contains (YOUTUBE_SHORT ) || linkText .contains (DAILYMOTION + ".com" ) || linkText .contains (VIMEO + ".com" ))) {
75+ } else if (!(linkText .contains (YOUTUBE + ".com" ) || linkText .contains (YOUTUBE_SHORT ) || linkText .contains (DAILYMOTION + ".com" ) || linkText .contains (METACAFE + ".com" ) || linkText . contains ( VIMEO + ".com" ))) {
7576 link .setError (context .getString (R .string .video_collection_template_linited_links ));
7677 return false ;
7778 }
@@ -99,7 +100,8 @@ private static boolean validated(Context context, EditText title, EditText descr
99100 return false ;
100101 } else if (!Patterns .WEB_URL .matcher (linkText ).matches ()){
101102 link .setError (context .getString (R .string .video_collection_template_link_valid_hint ));
102- } else if (!(linkText .contains (YOUTUBE + ".com" ) || linkText .contains (YOUTUBE_SHORT ) || linkText .contains (DAILYMOTION + ".com" ) || linkText .contains (VIMEO + ".com" ))) {
103+ return false ;
104+ } else if (!(linkText .contains (YOUTUBE + ".com" ) || linkText .contains (YOUTUBE_SHORT ) || linkText .contains (DAILYMOTION + ".com" ) || linkText .contains (METACAFE + ".com" ) || linkText .contains (VIMEO + ".com" ))) {
103105 link .setError (context .getString (R .string .video_collection_template_linited_links ));
104106 return false ;
105107 }
@@ -191,6 +193,18 @@ private String convertLink(String link) {
191193
192194 String VIMEO_OEMBED_LINK = "https://vimeo.com/api/oembed.json?url=" ;
193195 return VIMEO_OEMBED_LINK + link ;
196+ } else if (link .contains (METACAFE )) {
197+ if (!link .contains ("www." )) {
198+ link = "http://www." + link ;
199+ } else if (!(link .contains ("http:" ) || link .contains ("https:" ))) {
200+ link = "http://" + link ;
201+ }
202+ if (!link .endsWith ("/" )) {
203+ link = link +"/" ;
204+ }
205+ link .replaceFirst ("https://" ,"http://" );
206+
207+ return link ;
194208 }
195209
196210 return null ;
@@ -409,7 +423,7 @@ protected String doInBackground(String... params) {
409423 success = true ;
410424 final String BASE_URL = params [0 ];
411425
412- if (BASE_URL .contains (YOUTUBE + ".com" )) {
426+ if (BASE_URL .contains (YOUTUBE + ".com" ) || BASE_URL . contains ( METACAFE + ".com" ) ) {
413427 try {
414428 int TIMEOUT_LIMIT = 60000 ;
415429 String USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36" ;
@@ -424,8 +438,15 @@ protected String doInBackground(String... params) {
424438 String META_CONTENT = "content" ;
425439 String title = titleElem .attr (META_CONTENT );
426440
427- org .jsoup .nodes .Element inputElements = document .getElementById ("watch-description-text" );
428- String description = inputElements .html ();
441+ String description = "" ;
442+ if (BASE_URL .contains (YOUTUBE + ".com" )) {
443+ org .jsoup .nodes .Element inputElements = document .getElementById ("watch-description-text" );
444+ description = inputElements .html ();
445+ } else if (BASE_URL .contains (METACAFE + ".com" )) {
446+ String META_PROPERTY_DESCRIPTION = "meta[name=description]" ;
447+ Elements descriptionElem = document .select (META_PROPERTY_DESCRIPTION );
448+ description = descriptionElem .attr (META_CONTENT );
449+ }
429450
430451 //String META_PROPERTY_DESCRIPTION = "meta[property=og:description]";
431452 //Elements descriptionElem = document.select(META_PROPERTY_DESCRIPTION);
0 commit comments