/** * Returns file extension from url. * * @param url * the url * @return file extension or empty string * @throws URISyntaxException * if url is not valid */ public static String getFileExtension(String url) throws URISyntaxException { String ext = getURIEncoded(url).getPath(); if (ext == null || ext.isEmpty() || !ext.contains(".")) { LOGGER.warn("Url " + url + " has no extension!"); return ""; } else { ext = getFileNameArray(url)[1]; return ext; } }
/** * generates a valid user-agent <br> * something like:<br> * Mozilla/5.0 (Windows; Windows NT 6.1; Windows 7 6.1; U; amd64; de-DE; rv:26.0) Gecko/20100101 Firefox/26.0<br> * but with correct OS and language values */ public static String generateUA() { return generateUA(Locale.getDefault().getLanguage()); }
/** * Returns the the entire Url Path except the filename, like doing a basedir on a filename. * * @param url * the url * @return the base url */ public static String getBaseUrl(String url) { String path = getPathName(url); if (path != null && path.contains("/")) { path = path.substring(0, path.lastIndexOf('/')); } return getDomainUrl(url) + path; }
ext = UrlUtil.getExtension(url).toLowerCase(Locale.ROOT); if (!ext.isEmpty()) { if (Globals.settings.getAllSupportedFileTypes().contains("." + ext)) { StreamingUrl u = new StreamingUrl(UrlUtil.getURIEncoded(url).toASCIIString()); if (StringUtils.isNotBlank(userAgent)) { u.setUserAgent(userAgent);
Locale l = getLocaleFromLanguage(language);
url = getURIEncoded(url).toString(); path = new URL(url).getPath();
/** * Gets the actor name in a storage-able format (without special characters) * * @return the <i>cleaned</i> name for storing */ public String getNameForStorage() { String n = name.replace(" ", "_"); n = n.replaceAll("([\"\\\\:<>|/?*])", ""); String ext = UrlUtil.getExtension(this.thumbUrl); if (ext.isEmpty()) { ext = "jpg"; } return n + "." + ext; }
/** * gets the FileName (with extension) of an URL (better than commons-io) * * @param url * the to get the file name from * @return BaseName */ public static String getFilename(String url) { return getFileNameArray(url)[2]; }
/** * Return search url. * * <pre> * $$1 is title * $$2 is date * </pre> * * @param title * @return */ public KodiUrl getSearchUrl(String title, String date) throws Exception { if (date == null) date = ""; String url = scraperProcessor.executeFunction(FUNCTION_CREATE_SEARCH_URL, new String[] { "", UrlUtil.encode(title), URLEncoder.encode(date, "UTF-8") }); if (!StringUtils.isEmpty(url)) { return new KodiUrl(url); } else { return null; } }
Locale localeFromLanguage = UrlUtil.getLocaleFromLanguage(language); if (localeFromLanguage != null) { String combined = language + "-" + localeFromLanguage.getCountry().toLowerCase(Locale.ROOT);
String ext = UrlUtil.getExtension(url); if (ext.isEmpty()) { ext = "jpg"; // just assume
/** * gets the BaseName (w/o extension) of an URL (better than commons-io) * * @param url * the to get the base name from * @return BaseName */ public static String getBasename(String url) { return getFileNameArray(url)[0]; }
if (!FilenameUtils.getExtension(path.getFileName().toString()).equalsIgnoreCase(UrlUtil.getExtension(actor.getThumbUrl()))) { found = false;
/** * gets the Extension of an URL (better than commons-io) * * @param url * the to get the extension from * @return BaseName */ public static String getExtension(String url) { return getFileNameArray(url)[1]; }
/** * Instantiates a new url / httpclient with default user-agent. * * @param url * the url */ public Url(String url) throws MalformedURLException { if (client == null) { client = TmmHttpClient.getHttpClient(); } this.url = url; if (url.contains("|")) { splitHeadersFromUrl(); } // morph to URI to check syntax of the url try { uri = morphStringToUri(url); } catch (URISyntaxException e) { throw new MalformedURLException(url); } // default user agent addHeader(USER_AGENT, UrlUtil.generateUA()); }
String ext = UrlUtil.getExtension(trailer.getUrl()).toLowerCase(Locale.ROOT); if (!Globals.settings.getVideoFileType().contains("." + ext)) {