Skip to content
This repository was archived by the owner on Nov 28, 2024. It is now read-only.

Commit 2873a49

Browse files
committed
version 0.9
Corrections for history file inspection Enhancement: no double download for several emissions of same episode of a movie / film
1 parent b34bd8f commit 2873a49

File tree

7 files changed

+30
-13
lines changed

7 files changed

+30
-13
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Scripts/
33
pyvenv.cfg
44
.vscode/
5+
test_dl/
56

67
# Byte-compiled / optimized / DLL files
78
__pycache__/

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,14 @@ Options:
6565
#!/bin/sh
6666
#encoding: utf8
6767
68-
#go to the work directory
68+
#Go to the directory of the venv - where this script should be located
6969
cd /volumeX/[path]
7070
7171
#Download using the venv
72-
bin/python3 cleanup-generic.py /volume1/video/Kinder/Löwenzahn "https://mediathekviewweb.de/feed?query=%23L%C3%B6wenzahn%20%20%3E20"
72+
bin/python3 -m mediathekDownloader -S -m 20 -v -s '!ARD #Maus >10 <40' /volume1/video/Maus
7373

74-
#Index neu aufbauen
75-
/usr/syno/bin/synoindex -R /volume1/video/Kinder/Löwenzahn &
76-
#/usr/syno/bin/synoindex -R /volume1/video/Kinder/Maus &
77-
#/usr/syno/bin/synoindex -R /volume1/video/Kinder/MausSpezial/ &
74+
#Rebuild video station's index
75+
/usr/syno/bin/synoindex -R /volume1/video/Maus &
7876
```
7977

8078
## Installation

mediathekDownloader/__main__.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,31 @@ def fileIsInHistory(outPath : str, fileName : str) -> bool:
154154
historyFile = '%s/downloaded.txt' % outPath
155155
with open( historyFile, 'rt') as history:
156156
for line in history:
157-
if line == fileName:
157+
if line.rstrip() == fileName:
158158
isInHistory = True
159159
debug('File already in download history.')
160160
break
161161
except:
162162
pass
163163
return isInHistory
164164

165+
localQueue = []
166+
167+
def isFileInLocalQueue(term : str) -> bool:
168+
169+
global localQueue
170+
isQueued = False
171+
172+
for queuedItem in localQueue:
173+
if term == queuedItem:
174+
isQueued = True
175+
debug('File already considered for queue.')
176+
break
177+
178+
if isQueued == False:
179+
localQueue.append(term)
180+
181+
return isQueued
165182

166183
def retrieveFeed(feedUrl:str, outputPath:str, printFeedItems:bool=False)->[]:
167184

@@ -182,10 +199,11 @@ def retrieveFeed(feedUrl:str, outputPath:str, printFeedItems:bool=False)->[]:
182199

183200
skip = skipDedicatedEpisodeVariants(vsInfo.episodeTitle)
184201
existsAlready = determineFileAlreadyExists(downloadQueueItem.fullFilePath())
185-
isInHistory = fileIsInHistory(downloadQueueItem.path, downloadQueueItem.fileName)
202+
isInHistory = ( fileIsInHistory(downloadQueueItem.path, downloadQueueItem.fileName) ) or ( fileIsInHistory(downloadQueueItem.path, vsInfo.identifyingTerm ) )
186203
isInPast = True if (vsInfo.episodeReleaseDate < datetime.now().date()) else False
204+
isAlreadyQueued = isFileInLocalQueue( vsInfo.identifyingTerm )
187205

188-
if skip == False and existsAlready == False and isInHistory == False and isInPast == True:
206+
if skip == False and existsAlready == False and isInHistory == False and isInPast == True and isAlreadyQueued == False:
189207
downloadQueueItems.append(downloadQueueItem)
190208
if printFeedItems: printFeedItem(entry)
191209
else:
@@ -218,6 +236,7 @@ def downloadFeedItem(dlQuItem:DownloadQueueItem, barIndicator:bool=True) -> bool
218236

219237
information('File downloaded: %s' % (dlQuItem.vsInfo.episodeTitle))
220238
notedownDownload(dlQuItem.path, dlQuItem.fileName)
239+
notedownDownload(dlQuItem.path, dlQuItem.vsInfo.identifyingTerm)
221240
success = True
222241

223242
return success

mediathekDownloader/downloadQueueItem.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import os
22
from .vsMetaInfoGenerator import VsMetaInfoGenerator
33

4-
# TODO Filename Param ausbauen
5-
64
class DownloadQueueItem():
75
def __init__(self, vsInfo: VsMetaInfoGenerator, path: str):
86

mediathekDownloader/vsMetaInfoGenerator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ def __init__(self, feedItem):
4141
self.episodeLocked = False
4242
self.tvshowLocked = False
4343

44+
self.identifyingTerm = '%s - %s -s%se%s' % (self.showTitle, self.episodeTitle, self.season, self.episode)
45+
4446
def isUsable(self) ->bool:
4547
if (len(self.episodeTitle) > 0 or len(self.showTitle) > 0 or len(self.showTitle2) > 0) and len(self.download_url) > 0:
4648
return True

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
long_description = fh.read()
55

66
setuptools.setup(name='mediathekDownloader',
7-
version='0.1.2',
7+
version='0.9.0',
88
description=' Downloads series and movies from German public media libraries (Öffentlich-Rechtliche Sender) to your Synology NAS, for use with Synology Video Station.',
99
long_description=long_description,
1010
long_description_content_type="text/markdown",

todo.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)