Guest User

Untitled

a guest
Nov 23rd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 4.58 KB | None | 0 0
  1. diff -crB youtube-dl-github/youtube-dl youtube-dl-modified/youtube-dl
  2. *** youtube-dl-github/youtube-dl    2011-09-12 20:09:03.515998416 -0400
  3. --- youtube-dl-modified/youtube-dl  2011-09-12 20:07:00.957530608 -0400
  4. ***************
  5. *** 435,440 ****
  6. --- 435,441 ----
  7.     retries:          Number of times to retry for HTTP error 5xx
  8.     continuedl:       Try to continue downloads if possible.
  9.     noprogress:       Do not print the progress bar.
  10. +   percentstop:     Stop at a specific percent into the download.
  11.     playliststart:    Playlist item to start at.
  12.     playlistend:      Playlist item to end at.
  13.     logtostderr:      Log messages to stderr instead of stdout.
  14. ***************
  15. *** 482,495 ****
  16.         return '%6s' % ('%3.1f%%' % (float(byte_counter) / float(data_len) * 100.0))
  17.  
  18.     @staticmethod
  19. !   def calc_eta(start, now, total, current):
  20.         if total is None:
  21.             return '--:--'
  22.         dif = now - start
  23.         if current == 0 or dif < 0.001: # One millisecond
  24.             return '--:--'
  25.         rate = float(current) / dif
  26. !       eta = long((float(total) - float(current)) / rate)
  27.         (eta_mins, eta_secs) = divmod(eta, 60)
  28.         if eta_mins > 99:
  29.             return '--:--'
  30. --- 483,499 ----
  31.         return '%6s' % ('%3.1f%%' % (float(byte_counter) / float(data_len) * 100.0))
  32.  
  33.     @staticmethod
  34. !   def calc_eta(self, start, now, total, current):
  35.         if total is None:
  36.             return '--:--'
  37.         dif = now - start
  38.         if current == 0 or dif < 0.001: # One millisecond
  39.             return '--:--'
  40.         rate = float(current) / dif
  41. !       part = float(self.params.get('percentstop',100)) / 100 * float(total)
  42. !       finaltotal = float(total) - float(part)
  43. !
  44. !       eta = long((float(finaltotal) - float(current)) / rate)
  45.         (eta_mins, eta_secs) = divmod(eta, 60)
  46.         if eta_mins > 99:
  47.             return '--:--'
  48. ***************
  49. *** 926,931 ****
  50. --- 930,936 ----
  51.         byte_counter = 0 + resume_len
  52.         block_size = 1024
  53.         start = time.time()
  54. +       percentstop = 0;
  55.         while True:
  56.             # Download and write
  57.             before = time.time()
  58. ***************
  59. *** 954,962 ****
  60.  
  61.             # Progress message
  62.             percent_str = self.calc_percent(byte_counter, data_len)
  63. !           eta_str = self.calc_eta(start, time.time(), data_len - resume_len, byte_counter - resume_len)
  64.             speed_str = self.calc_speed(start, time.time(), byte_counter - resume_len)
  65.             self.report_progress(percent_str, data_len_str, speed_str, eta_str)
  66.  
  67.             # Apply rate limit
  68.             self.slow_down(start, byte_counter - resume_len)
  69. --- 959,972 ----
  70.  
  71.             # Progress message
  72.             percent_str = self.calc_percent(byte_counter, data_len)
  73. !           eta_str = self.calc_eta(self, start, time.time(), data_len - resume_len, byte_counter - resume_len)
  74.             speed_str = self.calc_speed(start, time.time(), byte_counter - resume_len)
  75.             self.report_progress(percent_str, data_len_str, speed_str, eta_str)
  76. +          
  77. +           if int(round(float(string.replace(percent_str,'%','')))) > int(self.params.get('percentstop',100)):
  78. +               percentstop = 1
  79. +               self.to_screen(u'\nDone. Downloaded at least %s percent.' % str(self.params.get('percentstop',100)))
  80. +               break
  81.  
  82.             # Apply rate limit
  83.             self.slow_down(start, byte_counter - resume_len)
  84. ***************
  85. *** 966,972 ****
  86.             return False
  87.         stream.close()
  88.         self.report_finish()
  89. !       if data_len is not None and byte_counter != data_len:
  90.             raise ContentTooShortError(byte_counter, long(data_len))
  91.         self.try_rename(tmpfilename, filename)
  92.  
  93. --- 976,982 ----
  94.             return False
  95.         stream.close()
  96.         self.report_finish()
  97. !       if data_len is not None and byte_counter != data_len and percentstop == 0:
  98.             raise ContentTooShortError(byte_counter, long(data_len))
  99.         self.try_rename(tmpfilename, filename)
  100.  
  101. ***************
  102. *** 3379,3384 ****
  103. --- 3389,3396 ----
  104.             dest='ratelimit', metavar='LIMIT', help='download rate limit (e.g. 50k or 44.6m)')
  105.     general.add_option('-R', '--retries',
  106.             dest='retries', metavar='RETRIES', help='number of retries (default is 10)', default=10)
  107. +   general.add_option('--percentstop',
  108. +           dest='percentstop', metavar='NUMBER', help='stop at a set percent (default is 100)', default=100)
  109.     general.add_option('--playlist-start',
  110.             dest='playliststart', metavar='NUMBER', help='playlist video to start at (default is 1)', default=1)
  111.     general.add_option('--playlist-end',
  112. ***************
  113. *** 3602,3607 ****
  114. --- 3614,3620 ----
  115.         'retries': opts.retries,
  116.         'continuedl': opts.continue_dl,
  117.         'noprogress': opts.noprogress,
  118. +       'percentstop': opts.percentstop,
  119.         'playliststart': opts.playliststart,
  120.         'playlistend': opts.playlistend,
  121.         'logtostderr': opts.outtmpl == '-',
Add Comment
Please, Sign In to add comment