From f537abe9f3646c739beaf15076246a2f71a347e9 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 20 二月 2025 16:57:55 +0800
Subject: [PATCH] IOS广告增加区域屏蔽

---
 src/test/java/com/hxh/spring/test/live/TVLiveTest.java |  107 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 107 insertions(+), 0 deletions(-)

diff --git a/src/test/java/com/hxh/spring/test/live/TVLiveTest.java b/src/test/java/com/hxh/spring/test/live/TVLiveTest.java
index e009326..26c5f66 100644
--- a/src/test/java/com/hxh/spring/test/live/TVLiveTest.java
+++ b/src/test/java/com/hxh/spring/test/live/TVLiveTest.java
@@ -1,6 +1,15 @@
 package com.hxh.spring.test.live;
 
+import com.yeshi.buwan.dao.live.TVLiveChannelDao;
+import com.yeshi.buwan.domain.live.TVLiveChannel;
+import com.yeshi.buwan.domain.live.TVLiveProgramResource;
+import com.yeshi.buwan.exception.ParamsException;
 import com.yeshi.buwan.job.LiveJob;
+import com.yeshi.buwan.service.inter.live.TVLiveProgramResourceService;
+import com.yeshi.buwan.util.StringUtil;
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.jsoup.select.Elements;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.test.context.ContextConfiguration;
@@ -8,6 +17,10 @@
 import org.springframework.test.context.web.WebAppConfiguration;
 
 import javax.annotation.Resource;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Scanner;
 
 @RunWith(SpringJUnit4ClassRunner.class) //浣跨敤junit4杩涜娴嬭瘯
 @ContextConfiguration(locations = {"classpath:spring.xml"})
@@ -17,10 +30,104 @@
     @Resource
     private LiveJob liveJob;
 
+    @Resource
+    private TVLiveChannelDao tvLiveChannelDao;
+    @Resource
+    private TVLiveProgramResourceService tvLiveProgramResourceService;
+
     @Test
     public void syncMiGu() throws Exception {
         liveJob.updateMiGu("");
     }
 
+    /**
+     * 鏇存柊鑺傜洰鍗�
+     */
+    @Test
+    public void updatePrigrams() throws Exception {
+        liveJob.updatePrograms(null);
+    }
+
+    @Test
+    public void getDianShiMaoChannels() throws IOException {
+        Document doc = Jsoup.connect("https://www.tvmao.com/program_satellite/AHTV1-w4.html").userAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36").get();
+        Elements els = doc.getElementsByClass("chlsnav").get(0).getElementsByTag("ul").get(0).getElementsByTag("a");
+        for (int i = 0; i < els.size(); i++) {
+            System.out.println(els.get(i).text() + "#https://www.tvmao.com" +
+                    els.get(i).attr("href"));
+        }
+    }
+
+    @Test
+    public void getTVSOUChannels() throws IOException {
+        Document doc = Jsoup.connect("https://www.tvsou.com/epg/yangshi/").userAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36").get();
+        Elements els = doc.getElementsByClass("c_list_main").get(0).getElementsByTag("a");
+        for (int i = 0; i < els.size(); i++) {
+            System.out.println(els.get(i).text() + "#https://www.tvsou.com/" +
+                    els.get(i).attr("href"));
+        }
+    }
+
+    @Test
+    public void addProgramResource() throws FileNotFoundException {
+        Scanner scanner = new Scanner(new File("C:\\Users\\Administrator\\Desktop\\鏂板缓鏂囨湰鏂囨。 (2).txt"));
+        while (scanner.hasNextLine()) {
+            String line = scanner.nextLine();
+            String[] sts = line.split("#");
+            if (sts.length > 1) {
+                String name = sts[0];
+                String link = sts[1].trim();
+                String id = StringUtil.Md5(name);
+                TVLiveChannel channel = tvLiveChannelDao.get(id);
+                if (channel != null) {
+                    TVLiveProgramResource resource = new TVLiveProgramResource();
+                    resource.setChannelId(channel.getId());
+                    resource.setType(TVLiveProgramResource.TVLiveProgramResourceType.dianshimao);
+                    resource.setUrl(link);
+                    try {
+                        tvLiveProgramResourceService.add(resource);
+                    } catch (ParamsException e) {
+                        e.printStackTrace();
+                    }
+                }
+            }
+        }
+
+        scanner.close();
+    }
+
+
+    /**
+     * 鎼滆缃�
+     * @throws FileNotFoundException
+     */
+    @Test
+    public void addProgramResourceTVSOU() throws FileNotFoundException {
+        Scanner scanner = new Scanner(new File("C:\\Users\\Administrator\\Desktop\\鎼滆缃�.txt"));
+        while (scanner.hasNextLine()) {
+            String line = scanner.nextLine();
+            String[] sts = line.split("#");
+            if (sts.length > 1) {
+                String name = sts[0];
+                String link = sts[1].trim();
+                String id = StringUtil.Md5(name);
+                TVLiveChannel channel = tvLiveChannelDao.get(id);
+                if (channel != null) {
+                    TVLiveProgramResource resource = new TVLiveProgramResource();
+                    resource.setChannelId(channel.getId());
+                    resource.setType(TVLiveProgramResource.TVLiveProgramResourceType.tvsou);
+                    resource.setUrl(link);
+                    try {
+                        tvLiveProgramResourceService.add(resource);
+                    } catch (ParamsException e) {
+                        e.printStackTrace();
+                    }
+                }
+            }
+        }
+
+        scanner.close();
+    }
+
 
 }

--
Gitblit v1.8.0