How is it possible to get such an image format in my application?

http://img.youtube.com/vi/Rxo0Upfz48Q/0.jpg

Provided that the ID-Schnick will always change. Need to somehow divide the link into two components?

    2 answers 2

    String placeholder = "http://img.youtube.com/vi/%s/0.jpg" ... String url = String.format(placeholder, id); 

    In id should be an idish video, for example Rxo0Upfz48Q

    • I will get ID-schnick from the user, so I can not put all the values ​​there. - Inkognito
    • @Inkognito, that's when you get it, write it into the id variable, and execute the code that is in response - Vladyslav Matviienko
    • Do not tell me how to get the ID? In the sense that the user has already inserted a link, clicked ok for example, but I just output Toast. And how to pull out the ID from the link can not imagine. - Inkognito
    • @Inkognito well, show the link from which you need to pull the ID. In addition, the ID is not always present in the link. I told you in your previous question how to get an ID - Vladyslav Matviienko
    • Well, for example youtube.com/watch?v=Rxo0Upfz48Q and forgive, I do not see anything like that. - Inkognito

    If the user uploads the video, he will receive a link. Therefore you can try to use Pattern and then Matcher . Something like this:

     private static final Pattern rtmpUrlPattern = Pattern.compile("^rtmp://([^/:]+)(:(\\d+))*/([^/]+)(/(.*))*$"); Matcher matcher = rtmpUrlPattern.matcher(url); host = matcher.group(1); String portStr = matcher.group(3); port = portStr != null ? Integer.parseInt(portStr) : 1935; 
    • and what role does the group play here? - Inkognito
    • Well, you can write / read exactly Rxo0Upfz48Q - Morozov