mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-01-31 10:54:50 +01:00
Check network for every media file, manually check suspiciously low file sizes
This commit is contained in:
parent
4f84ceff73
commit
23a3e7c766
@ -30,13 +30,20 @@ public class FeedMediaSizeService extends IntentService {
|
||||
}
|
||||
List<FeedMedia> list = DBReader.getFeedMediaUnknownSize(this);
|
||||
for (FeedMedia media : list) {
|
||||
long size = -1;
|
||||
if(false == NetworkUtils.networkAvailable(this)) {
|
||||
return;
|
||||
}
|
||||
long size = Integer.MIN_VALUE;
|
||||
Log.d(TAG, media.getDownload_url());
|
||||
try {
|
||||
URL url = new URL(media.getDownload_url());
|
||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestProperty( "Accept-Encoding", "" );
|
||||
conn.setRequestMethod("HEAD");
|
||||
size = conn.getContentLength();
|
||||
conn.disconnect();
|
||||
} catch (IOException e) {
|
||||
Log.d(TAG, media.getDownload_url());
|
||||
e.printStackTrace();
|
||||
}
|
||||
media.setSize(size);
|
||||
|
@ -551,11 +551,11 @@ public final class DBReader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the IDs of the FeedItems whose 'read'-attribute is set to false.
|
||||
* Loads FeedMedia whose file size is unknown
|
||||
*
|
||||
* @param context A context that is used for opening a database connection.
|
||||
* @return A list of IDs of the FeedItems whose 'read'-attribute is set to false. This method should be preferred
|
||||
* over {@link #getUnreadItemsList(android.content.Context)} if the FeedItems in the UnreadItems list are not used.
|
||||
* @return A list of FeedMedia items whose size is 0 (unknown and never tried to
|
||||
* determine the correct size)
|
||||
*/
|
||||
public static List<FeedMedia> getFeedMediaUnknownSize(Context context) {
|
||||
PodDBAdapter adapter = new PodDBAdapter(context);
|
||||
|
@ -1108,7 +1108,7 @@ public class PodDBAdapter {
|
||||
public final Cursor getFeedMediaUnknownSizeCursor() {
|
||||
final String query = "SELECT * "
|
||||
+ " FROM " + TABLE_NAME_FEED_MEDIA
|
||||
+ " WHERE " + KEY_SIZE + "=0";
|
||||
+ " WHERE " + KEY_SIZE + ">" + Integer.MIN_VALUE;
|
||||
return db.rawQuery(query, null);
|
||||
}
|
||||
|
||||
|
@ -57,6 +57,10 @@ public class NSRSS20 extends Namespace {
|
||||
long size = 0;
|
||||
try {
|
||||
size = Long.parseLong(attributes.getValue(ENC_LEN));
|
||||
if(size < 16384) {
|
||||
// less than 16kb is suspicious, check manually
|
||||
size = 0;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Length attribute could not be parsed.");
|
||||
|
Loading…
x
Reference in New Issue
Block a user