question: public static int extractQuality ( String url ) { { Pattern u = Pattern . compile ( "youtube.com/watch?.*fmt=([^&]*)" ) ; Matcher um = u . matcher ( url . toString ( ) ) ; if ( um . find ( ) ) { try { return Integer . parseInt ( um . group ( 1 ) ) ; } catch ( NumberFormatException e ) { } } } { Pattern u = Pattern . compile ( "youtube.com/v/.*fmt=([^&]*)" ) ; Matcher um = u . matcher ( url . toString ( ) ) ; if ( um . find ( ) ) { try { return Integer . parseInt ( um . group ( 1 ) ) ; } catch ( NumberFormatException e ) { } } } return 0 ; }
target:  extracts the quality id from the given url