60
60
61
61
62
62
def youtube_parsedate (s ):
63
- """Parse a string into a unix timestamp
63
+ """Parse a string into a unix timestamp.
64
64
65
65
Only strings provided by youtube-dl API are
66
66
parsed with this function (20170920).
@@ -71,18 +71,16 @@ def youtube_parsedate(s):
71
71
72
72
73
73
def video_guid (video_id ):
74
- """
75
- generate same guid as youtube
76
- """
74
+ """Generate same guid as youtube."""
77
75
return 'yt:video:{}' .format (video_id )
78
76
79
77
80
78
class YoutubeCustomDownload (download .CustomDownload ):
81
- """
82
- Represents the download of a single episode using youtube-dl.
79
+ """Represents the download of a single episode using youtube-dl.
83
80
84
81
Actual youtube-dl interaction via gPodderYoutubeDL.
85
82
"""
83
+
86
84
def __init__ (self , ytdl , url , episode ):
87
85
self ._ytdl = ytdl
88
86
self ._url = url
@@ -100,9 +98,7 @@ def partial_filename(self, val):
100
98
self ._partial_filename = val
101
99
102
100
def retrieve_resume (self , tempname , reporthook = None ):
103
- """
104
- called by download.DownloadTask to perform the download.
105
- """
101
+ """Called by download.DownloadTask to perform the download.""" # noqa: D401
106
102
self ._reporthook = reporthook
107
103
# outtmpl: use given tempname by DownloadTask
108
104
# (escape % because outtmpl used as a string template by youtube-dl)
@@ -177,9 +173,8 @@ def _my_hook(self, d):
177
173
178
174
179
175
class YoutubeFeed (model .Feed ):
180
- """
181
- Represents the youtube feed for model.PodcastChannel
182
- """
176
+ """Represents the youtube feed for model.PodcastChannel."""
177
+
183
178
def __init__ (self , url , cover_url , description , max_episodes , ie_result , downloader ):
184
179
self ._url = url
185
180
self ._cover_url = cover_url
@@ -222,12 +217,18 @@ def get_cover_url(self):
222
217
return self ._cover_url
223
218
224
219
def get_http_etag (self ):
225
- """ :return str: optional -- last HTTP etag header, for conditional request next time """
220
+ """Return the last HTTP etag header, for conditional request next time.
221
+
222
+ :return str: optional.
223
+ """
226
224
# youtube-dl doesn't provide it!
227
225
return None
228
226
229
227
def get_http_last_modified (self ):
230
- """ :return str: optional -- last HTTP Last-Modified header, for conditional request next time """
228
+ """Return the last HTTP Last-Modified header, for conditional request next time.
229
+
230
+ :return str: optional
231
+ """
231
232
# youtube-dl doesn't provide it!
232
233
return None
233
234
@@ -274,8 +275,8 @@ def get_new_episodes(self, channel, existing_guids):
274
275
return episodes , all_seen_guids
275
276
276
277
def get_next_page (self , channel , max_episodes ):
277
- """
278
- Paginated feed support (RFC 5005).
278
+ """Paginated feed support (RFC 5005).
279
+
279
280
If the feed is paged, return the next feed page.
280
281
Returned page will in turn be asked for the next page, until None is returned.
281
282
:return feedcore.Result: the next feed's page,
@@ -322,7 +323,7 @@ def __init__(self, gpodder_config, my_config, force=False):
322
323
self ._ydl_opts ['logger' ] = logger
323
324
324
325
def add_format (self , gpodder_config , opts , fallback = None ):
325
- """ construct youtube-dl -f argument from configured format. """
326
+ """Construct youtube-dl -f argument from configured format."""
326
327
# You can set a custom format or custom formats by editing the config for key
327
328
# `youtube.preferred_fmt_ids`
328
329
#
@@ -447,9 +448,10 @@ def extract_type(ie_result):
447
448
YoutubeFeed (url , cover_url , description , max_episodes , ie_result , self ))
448
449
449
450
def fetch_channel (self , channel , max_episodes = 0 ):
450
- """
451
- called by model.gPodderFetcher to get a custom feed.
452
- :returns feedcore.Result: a YoutubeFeed or None if channel is not a youtube channel or playlist
451
+ """Return a custom feed. Called by model.gPodderFetcher.
452
+
453
+ :returns feedcore.Result: A YoutubeFeed or None if channel is not
454
+ a youtube channel or playlist
453
455
"""
454
456
if not self .my_config .manage_channel :
455
457
return None
@@ -493,9 +495,7 @@ def is_supported_url(self, url):
493
495
return False
494
496
495
497
def custom_downloader (self , unused_config , episode ):
496
- """
497
- called from registry.custom_downloader.resolve
498
- """
498
+ """Called from registry.custom_downloader.resolve.""" # noqa: D401
499
499
if not self .force and not self .my_config .manage_downloads :
500
500
return None
501
501
0 commit comments