| | |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.yeshi.buwan.mogotv.entity.MogoTVClipInfo; |
| | | import com.yeshi.buwan.mogotv.entity.MogoTVVideo; |
| | | import com.yeshi.buwan.youku.entity.YouKuShowDetail; |
| | | import com.yeshi.buwan.youku.entity.YouKuShowSimple; |
| | | import com.yeshi.buwan.youku.entity.YouKuVideo; |
| | | import net.sf.json.JSONArray; |
| | | import net.sf.json.JSONObject; |
| | | import org.yeshi.utils.HttpUtil; |
| | | import org.yeshi.utils.StringUtil; |
| | | |
| | | import javax.script.Invocable; |
| | | import javax.script.ScriptEngine; |
| | | import javax.script.ScriptEngineManager; |
| | | import javax.script.ScriptException; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.lang.reflect.Type; |
| | | import java.net.URLEncoder; |
| | | import java.util.*; |
| | | |
| | | public class MogoTVApiUtil { |
| | |
| | | // https://pcweb.api.mgtv.com/episode/list?src=intelmgtv&abroad=0&_support=10000000&version=5.5.35&video_id=11026579&page=0&size=30&abroad=0&src=intelmgtv&callback=jsonp_1616648013585_27530 |
| | | // |
| | | // isIntact:1表示正片 |
| | | |
| | | |
| | | private final static String APP_ID = "758bef946d0050ef"; |
| | | private final static String APP_SECRET = "e113a131d49e1f837402e2807f2daf58"; |
| | | |
| | | |
| | | private static ScriptEngine jsEngine; |
| | | |
| | | |
| | |
| | | String script = "function getData(){ return " + result + ";}\n"; |
| | | script += String.format("function %s(t){return t;}", callback); |
| | | jsEngine.eval(script); |
| | | } catch ( |
| | | ScriptException e) { |
| | | } catch (ScriptException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | |
| | | data = data.optJSONObject("data"); |
| | | |
| | | int totalPage = data.optInt("total_page"); |
| | | JSONArray list = data.optJSONArray("list"); |
| | | JSONObject list = data.optJSONObject("list"); |
| | | JSONArray array = null; |
| | | if (list.isArray()) { |
| | | array = data.optJSONArray("list"); |
| | | } else { |
| | | array = new JSONArray(); |
| | | for (Iterator<String> its = list.keys(); its.hasNext(); ) { |
| | | String key = its.next(); |
| | | array.add(list.optJSONObject(key)); |
| | | } |
| | | |
| | | } |
| | | Type type = new TypeToken<List<MogoTVVideo>>() { |
| | | }.getType(); |
| | | List<MogoTVVideo> videoList = new Gson().fromJson(list.toString(), type); |
| | | List<MogoTVVideo> videoList = new Gson().fromJson(array.toString(), type); |
| | | for (int i = 0; i < videoList.size(); i++) { |
| | | if (videoList.get(i).getIsIntact() != 1) { |
| | | videoList.remove(i--); |
| | |
| | | clipInfo.setLanguage(detail.optString("language")); |
| | | clipInfo.setFstlvlType(detail.optString("fstlvlType")); |
| | | clipInfo.setStory(detail.optString("story")); |
| | | String updateInfo = detail.optString("updateInfo"); |
| | | updateInfo = updateInfo.replace("更新到", "更新至"); |
| | | if (updateInfo.contains(",")) |
| | | updateInfo = updateInfo.split(",")[updateInfo.split(",").length - 1]; |
| | | clipInfo.setUpdateInfo(updateInfo); |
| | | return clipInfo; |
| | | } |
| | | return null; |