@@ -45,17 +45,6 @@ public class VideoCollectionTemplate implements TemplateInterface {
4545 private static final String YOUTUBE_SHORT = "youtu.be" ;
4646 private static final String DAILYMOTION = "dailymotion" ;
4747 private static final String VIMEO = "vimeo" ;
48- private final String JSON_TITLE = "title" ;
49- private final String JSON_DESCRIPTION = "description" ;
50- private final String JSON_THUMBNAIL_URL = "thumbnail_url" ;
51- private final String META_PROPERTY_TITLE = "meta[property=og:title]" ;
52- private final String META_PROPERTY_DESCRIPTION = "meta[property=og:description]" ;
53- private final String META_PROPERTY_THUMBNAIL_URL = "meta[property=og:image]" ;
54- private final String META_CONTENT = "content" ;
55- private final String USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36" ;
56- private final int TIMEOUT_LIMIT = 60000 ;
57- private final String DAILYMOTION_OEMBED_LINK = "http://www.dailymotion.com/services/oembed?url=" ;
58- private final String VIMEO_OEMBED_LINK = "https://vimeo.com/api/oembed.json?url=" ;
5948 private final String TEMPLATE_NAME = "VideoCollection Template" ;
6049 transient private VideoCollectionAdapter adapter ;
6150 private ArrayList <VideoModel > videoData ;
@@ -187,13 +176,15 @@ private String convertLink(String link) {
187176 link = "https://" + link ;
188177 }
189178
179+ String DAILYMOTION_OEMBED_LINK = "http://www.dailymotion.com/services/oembed?url=" ;
190180 return DAILYMOTION_OEMBED_LINK + link ;
191181
192182 } else if (link .contains (VIMEO )) {
193183 if (!(link .contains ("http:" ) || link .contains ("https:" ))) {
194184 link = "https://" + link ;
195185 }
196186
187+ String VIMEO_OEMBED_LINK = "https://vimeo.com/api/oembed.json?url=" ;
197188 return VIMEO_OEMBED_LINK + link ;
198189 }
199190
@@ -390,18 +381,24 @@ protected String doInBackground(String... params) {
390381
391382 if (BASE_URL .contains (YOUTUBE + ".com" )) {
392383 try {
384+ int TIMEOUT_LIMIT = 60000 ;
385+ String USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36" ;
393386 org .jsoup .nodes .Document document = Jsoup .connect (BASE_URL )
394387 .timeout (TIMEOUT_LIMIT )
395388 .userAgent (USER_AGENT )
396389 .ignoreContentType (true )
397390 .get ();
398391
392+ String META_PROPERTY_TITLE = "meta[property=og:title]" ;
399393 Elements titleElem = document .select (META_PROPERTY_TITLE );
394+ String META_CONTENT = "content" ;
400395 String title = titleElem .attr (META_CONTENT );
401396
397+ String META_PROPERTY_DESCRIPTION = "meta[property=og:description]" ;
402398 Elements descriptionElem = document .select (META_PROPERTY_DESCRIPTION );
403399 String description = descriptionElem .attr (META_CONTENT );
404400
401+ String META_PROPERTY_THUMBNAIL_URL = "meta[property=og:image]" ;
405402 Elements thumbnailElem = document .select (META_PROPERTY_THUMBNAIL_URL );
406403 String thumbnail_url = thumbnailElem .attr (META_CONTENT );
407404
@@ -476,8 +473,11 @@ protected void onPostExecute(String result) {
476473
477474 try {
478475 JSONObject json = new JSONObject (result );
476+ String JSON_TITLE = "title" ;
479477 String title = json .getString (JSON_TITLE );
478+ String JSON_DESCRIPTION = "description" ;
480479 String description = json .getString (JSON_DESCRIPTION );
480+ String JSON_THUMBNAIL_URL = "thumbnail_url" ;
481481 String thumbnail_url = json .getString (JSON_THUMBNAIL_URL );
482482
483483 if (position .equals ("-1" )) {
0 commit comments