~ubuntu-branches/ubuntu/vivid/mediathekview/vivid

« back to all changes in this revision

Viewing changes to src/msearch/filmeSuchen/sender/MediathekSwr.java

  • Committer: Package Import Robot
  • Author(s): Markus Koschany
  • Date: 2014-10-24 12:49:46 UTC
  • mfrom: (4.1.12 sid)
  • Revision ID: package-import@ubuntu.com-20141024124946-rhnmiwad6apojoxt
Tags: 7.1-1
* Imported Upstream version 7.1.
* Declare compliance with Debian Policy 3.9.6.
* Update VCS-Browser field to new canonical address.
* Update man pages timestamp.
* Update debian/copyright for new release.
* Add README.source.
* Rename modify-ant-build-system.patch to build.patch and update it for 7.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 */
20
20
package msearch.filmeSuchen.sender;
21
21
 
 
22
import java.util.ArrayList;
22
23
import java.util.LinkedList;
23
24
import msearch.daten.DatenFilm;
24
25
import msearch.daten.MSConfig;
34
35
    private static final int wartenKurz = 2000;
35
36
    private static final int wartenLang = 4000;
36
37
 
37
 
    public static final String SENDER = "SWR";
 
38
    public final static String SENDERNAME = "SWR";
38
39
 
39
40
    public MediathekSwr(MSFilmeSuchen ssearch, int startPrio) {
40
 
        super(ssearch, /* name */ SENDER, /* threads */ 2, /* urlWarten */ wartenLang, startPrio);
 
41
        super(ssearch, SENDERNAME , /* threads */ 2, /* urlWarten */ wartenLang, startPrio);
41
42
    }
42
43
 
43
44
    //===================================
48
49
        meldungStart();
49
50
        //Theman suchen
50
51
        listeThemen.clear();
51
 
        addToList__("http://swrmediathek.de/tvlist.htm");
 
52
        addToList__();
52
53
        if (MSConfig.getStop()) {
53
54
            meldungThreadUndFertig();
54
55
        } else if (listeThemen.size() == 0) {
58
59
            for (int t = 0; t < maxThreadLaufen; ++t) {
59
60
                //new Thread(new ThemaLaden()).start();
60
61
                Thread th = new Thread(new ThemaLaden());
61
 
                th.setName(nameSenderMReader + t);
 
62
                th.setName(SENDERNAME + t);
62
63
                th.start();
63
64
            }
64
65
        }
67
68
    //===================================
68
69
    // private
69
70
    //===================================
70
 
    private void addToList__(String ADRESSE) {
 
71
    private void addToList__() {
71
72
        //Theman suchen
 
73
        final String MUSTER_START = "<div style=\"\" class=\"media mediaA\">";
72
74
        final String MUSTER_URL = "<a href=\"tvshow.htm?show=";
73
75
        final String MUSTER_THEMA = "title=\"";
74
76
        MSStringBuilder strSeite = new MSStringBuilder(MSConst.STRING_BUFFER_START_BUFFER);
75
 
        strSeite = getUrlIo.getUri(nameSenderMReader, ADRESSE, MSConst.KODIERUNG_UTF, 2, strSeite, "");
 
77
        strSeite = getUrlIo.getUri(SENDERNAME, "http://swrmediathek.de/tvlist.htm", MSConst.KODIERUNG_UTF, 2, strSeite, "");
76
78
        int pos = 0;
77
 
        int pos1;
78
 
        int pos2;
79
79
        String url;
80
 
        String thema = "";
81
 
        while (!MSConfig.getStop() && (pos = strSeite.indexOf(MUSTER_URL, pos)) != -1) {
82
 
            pos += MUSTER_URL.length();
83
 
            pos1 = pos;
84
 
            pos2 = strSeite.indexOf("\"", pos);
85
 
            if (pos1 != -1 && pos2 != -1 && pos1 != pos2) {
86
 
                url = strSeite.substring(pos1, pos2);
87
 
                pos = pos2;
88
 
                pos = strSeite.indexOf(MUSTER_THEMA, pos);
89
 
                pos += MUSTER_THEMA.length();
90
 
                pos1 = pos;
91
 
                pos2 = strSeite.indexOf("\"", pos);
92
 
                if (pos1 != -1 && pos2 != -1) {
93
 
                    thema = strSeite.substring(pos1, pos2);
94
 
                    thema = StringEscapeUtils.unescapeHtml4(thema.trim()); //wird gleich benutzt und muss dann schon stimmen
95
 
                }
96
 
                if (url.equals("")) {
97
 
                    MSLog.fehlerMeldung(-163255009, MSLog.FEHLER_ART_MREADER, "MediathekSwr.addToList__", "keine URL");
98
 
                } else {
99
 
                    //url = url.replace("&amp;", "&");
100
 
                    String[] add = new String[]{"http://swrmediathek.de/tvshow.htm?show=" + url, thema};
101
 
                    listeThemen.addUrl(add);
102
 
                }
 
80
        String thema;
 
81
        while (!MSConfig.getStop() && (pos = strSeite.indexOf(MUSTER_START, pos)) != -1) {
 
82
            pos += MUSTER_START.length();
 
83
            url = strSeite.extract(MUSTER_URL, "\"", pos);
 
84
            thema = strSeite.extract(MUSTER_THEMA, "\"", pos);
 
85
            thema = StringEscapeUtils.unescapeHtml4(thema.trim()); //wird gleich benutzt und muss dann schon stimmen
 
86
            if (thema.isEmpty()) {
 
87
                MSLog.fehlerMeldung(-915263078, MSLog.FEHLER_ART_MREADER, "MediathekSwr.addToList__", "kein Thema");
 
88
            }
 
89
            if (url.isEmpty()) {
 
90
                MSLog.fehlerMeldung(-163255009, MSLog.FEHLER_ART_MREADER, "MediathekSwr.addToList__", "keine URL");
 
91
            } else {
 
92
                //url = url.replace("&amp;", "&");
 
93
                String[] add = new String[]{"http://swrmediathek.de/tvshow.htm?show=" + url, thema};
 
94
                listeThemen.addUrl(add);
103
95
            }
104
96
        }
105
97
    }
109
101
        MSGetUrl getUrlThemaLaden = new MSGetUrl(MSConfig.senderAllesLaden ? wartenLang : wartenKurz);
110
102
        private MSStringBuilder strSeite1 = new MSStringBuilder(MSConst.STRING_BUFFER_START_BUFFER);
111
103
        private MSStringBuilder strSeite2 = new MSStringBuilder(MSConst.STRING_BUFFER_START_BUFFER);
 
104
        ArrayList<String> gefunden = new ArrayList<>();
112
105
 
113
106
        public ThemaLaden() {
114
107
        }
129
122
        }
130
123
 
131
124
        private void themenSeitenSuchen(String strUrlFeed, String thema) {
132
 
            final String MUSTER_URL = "<li><a class=\"plLink\" href=\"player.htm?show=";
 
125
            final String MUSTER_URL = "<a href=\"/player.htm?show=";
133
126
            //strSeite1 = getUrl.getUri_Utf(nameSenderMReader, strUrlFeed, strSeite1, thema);
134
 
            strSeite1 = getUrlThemaLaden.getUri(nameSenderMReader, strUrlFeed, MSConst.KODIERUNG_UTF, 2 /* versuche */, strSeite1, thema);
 
127
            strSeite1 = getUrlThemaLaden.getUri(SENDERNAME, strUrlFeed, MSConst.KODIERUNG_UTF, 2 /* versuche */, strSeite1, thema);
135
128
            meldung(strUrlFeed);
136
129
            int pos1 = 0;
137
130
            int pos2;
138
131
            String url;
139
132
            int max = 0;
 
133
            gefunden.clear();
140
134
            while (!MSConfig.getStop() && (pos1 = strSeite1.indexOf(MUSTER_URL, pos1)) != -1) {
141
135
                if (!MSConfig.senderAllesLaden) {
142
136
                    ++max;
152
146
                pos1 += MUSTER_URL.length();
153
147
                if ((pos2 = strSeite1.indexOf("\"", pos1)) != -1) {
154
148
                    url = strSeite1.substring(pos1, pos2);
 
149
                    if (gefunden.contains(url)) {
 
150
                        if (max > 0) {
 
151
                            --max;
 
152
                        }
 
153
                        continue;
 
154
                    } else {
 
155
                        gefunden.add(url);
 
156
                    }
155
157
                    if (url.equals("")) {
156
158
                        MSLog.fehlerMeldung(-875012369, MSLog.FEHLER_ART_MREADER, "MediathekSwr.addFilme2", "keine URL, Thema: " + thema);
157
159
                    } else {
160
162
                    }
161
163
 
162
164
                }
163
 
 
164
165
            }
 
166
            gefunden.clear();
165
167
        }
166
168
 
167
169
        private void json(String strUrlFeed, String thema, String urlJson) {
172
174
            // :"entry_media","attr":{"val0":"flashmedia","val1":"1","val2":"rtmp://fc-ondemand.swr.de/a4332/e6/swr-fernsehen/eisenbahn-romantik/381104.s.flv","val3":"rtmp://fc-ondemand.swr.de/a4332/e6/"},"sub":[]},{"name":"entry_media","attr":{"val0":"flashmedia","val1":"2","val2":"rtmp://fc-ondemand.swr.de/a4332/e6/swr-fernsehen/eisenbahn-romantik/381104.m.flv","val3":"rtmp://fc-ondemand.swr.de/a4332/e6/"},"sub":[]
173
175
            // "entry_title":"\"Troika-Tragödie - Verspielt die Regierung unser Steuergeld?\"
174
176
            try {
175
 
                strSeite2 = getUrlThemaLaden.getUri_Utf(nameSenderMReader, urlJson, strSeite2, "");
 
177
                strSeite2 = getUrlThemaLaden.getUri_Utf(SENDERNAME, urlJson, strSeite2, "");
176
178
                if (strSeite2.length() == 0) {
177
179
                    MSLog.fehlerMeldung(-95623451, MSLog.FEHLER_ART_MREADER, "MediathekSwr.json", "Seite leer: " + urlJson);
178
180
                    return;
199
201
                    if (smallUrl.isEmpty()) {
200
202
                        smallUrl = getSuperSmalUrl();
201
203
                    }
202
 
                    DatenFilm film = new DatenFilm(nameSenderMReader, thema, strUrlFeed, title, normalUrl, ""/*rtmpURL*/, date, time, duration, description,
 
204
                    DatenFilm film = new DatenFilm(SENDERNAME, thema, strUrlFeed, title, normalUrl, ""/*rtmpURL*/, date, time, duration, description,
203
205
                            thumbNailUrl, keywords);
204
206
 
205
207
                    if (!urldHd.isEmpty()) {