tubedl 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f7aca0352bc49355aee142f0913903b18d5d7d96
4
- data.tar.gz: 1fc9bc03efc8b2ed356cb2244e7b850668c74ba9
3
+ metadata.gz: bd2c1f4a4004fa14c561f8fd9265d24c9e37bc54
4
+ data.tar.gz: f4933c5b679f40fcd435e2f74dbe4accb6dcc7f1
5
5
  SHA512:
6
- metadata.gz: 13fdfa527bc320f182c21987801a99e66ab41e5b6b7159ae99c70c5133d1ad769a1914ccf88bc8536c054bfdf4122bea1562c18645403eefa1d89418384c7abf
7
- data.tar.gz: 78d6aa427cf44a6ded8771cfefae051189bb2d408147b0828d3abec2c85b208b2907e745e69cb2cf8d31badd41da3646b0e392d97b580dc684d722040f8bbeac
6
+ metadata.gz: 71ca7a08ff2eb693bf46abba4096b20bf8087ae57613f8d3e83fd8beb92b7fd40e9da66aaeaf4357e4108d9dea2bd26960f929b15fd1b7456779dc82d1619e2d
7
+ data.tar.gz: cdeb4fdb063c0f532882f43bbceb8223e6b0a71e7a5b6d1fb88f2059a4da3f236668725d5180397f9b97117971e32452c5807e2d6e16e74da4d61dcd44bb4dbb
data/README.md CHANGED
@@ -24,7 +24,7 @@ Or install it yourself as:
24
24
 
25
25
  ```ruby
26
26
  require 'tubedl'
27
- metallica = Tubedl.Playlist.new 'https://www.youtube.com/playlist?list=PLJvQXRgtxlumAHceNRk3cx3P7MZVUCdBl'
27
+ metallica = Tubedl::Playlist.new 'https://www.youtube.com/playlist?list=PLJvQXRgtxlumAHceNRk3cx3P7MZVUCdBl'
28
28
 
29
29
  first_song = metallica.video0001
30
30
  object_instances = metallica.instance_variables
@@ -37,11 +37,14 @@ specific_resulation = Tubedl.set_quality(first_song_link, 'hd1080')
37
37
  metallica.save_playlist
38
38
  metallica.save_smplayer_playlist # That will create a smplayer playlist
39
39
  # Also can pass path as argument
40
- metallica.save_smplayer_playlist '/home/gcaglar/Music'
41
- metallica.save_playlist '/home/gcaglar/Music'
40
+ metallica.save_smplayer_playlist '/home/[USERNAME]/Music'
41
+ metallica.save_playlist '/home/[USERNAME]/Music'
42
42
  # Tubedl.load_playlist(path)
43
43
  Tubedl.save_object(metallica)
44
44
 
45
+ # Also can save a yaml playlist as a smplayer playlist
46
+ Tubedl.yaml_to_smplayer('/home/[USERNAME]/Music/Playlist-19-8-2017.yml', '/home/[USERNAME]/Music')
47
+
45
48
  # Rusults
46
49
  puts first_song
47
50
  puts first_songID
@@ -6,7 +6,7 @@ require 'yaml'
6
6
 
7
7
  module Tubedl
8
8
  include PlaylistParser
9
-
9
+
10
10
  QULITIES = {
11
11
  hd1440: '?version=3&vq=hd1440',
12
12
  hd1080: '?version=3&vq=hd1080',
@@ -15,7 +15,7 @@ module Tubedl
15
15
  sd360: '?version=3&vq=medium',
16
16
  sd240: '?version=3&vq=small'
17
17
  }
18
-
18
+
19
19
  def self.get_videoID(link)
20
20
  link.match(PlaylistParser::YoutubeRegex)[5]
21
21
  end
@@ -23,7 +23,7 @@ module Tubedl
23
23
  def self.set_quality(str, quality)
24
24
  str + QULITIES[quality.to_sym]
25
25
  end
26
-
26
+
27
27
  def self.get_page_data(url)
28
28
  begin
29
29
  doc = Nokogiri::HTML(open(url).read)
@@ -34,12 +34,22 @@ module Tubedl
34
34
  end
35
35
  doc
36
36
  end
37
-
37
+
38
38
  def self.load_playlist(file_path)
39
39
  YAML.load_file(file_path)
40
40
  end
41
-
41
+
42
42
  def self.save_object(object)
43
43
  File.write("#{object}.yml", YAML.dump(object))
44
44
  end
45
+
46
+ def self.yaml_to_smplayer(file, path_to_save = nil)
47
+ hash = YAML.load(File.read(file))
48
+ f = File.open("#{path_to_save || '.'}/smplayerPlaylist-#{@playlistID}-#{Time.now.to_a[3..5].join('-')}.m3u", "w+")
49
+ f.write("#EXTM3U\n")
50
+ hash.each_pair do |k, v|
51
+ f.puts("#EXTINF:0,#{k}\n#{v}\n")
52
+ end
53
+ f.close
54
+ end
45
55
  end
@@ -1,9 +1,9 @@
1
1
  module PlaylistParser
2
2
  YoutubeRegex = /(youtu\.be\/|youtube\.com\/(watch\?(.*&)?v=|(embed|v)\/))([^\?&"'>]+)/
3
-
3
+
4
4
  class Playlist
5
5
  attr_reader :playlistID, :playlist, :playlist_data
6
-
6
+
7
7
  def initialize(link = nil)
8
8
  counter = 'video0000'
9
9
  link ||= link_generator
@@ -14,7 +14,7 @@ module PlaylistParser
14
14
  self.class.send(:attr_reader, counter)
15
15
  end
16
16
  end
17
-
17
+
18
18
  def link_generator(ln = nil)
19
19
  print 'Please Enter A Correct Playlist Link: ' unless ln || ARGV[0]
20
20
  ln ||= ARGV[0] || gets.chomp
@@ -24,7 +24,7 @@ module PlaylistParser
24
24
  link_generator
25
25
  end
26
26
  end
27
-
27
+
28
28
  def parse_page(page)
29
29
  playlist_data = page.css('table.pl-video-table')
30
30
  if playlist_data
@@ -34,13 +34,13 @@ module PlaylistParser
34
34
  end
35
35
  songs_hashes
36
36
  end
37
-
37
+
38
38
  def is_playlist?(link)
39
39
  link.include? 'list' && 'playlist'
40
40
  end
41
41
 
42
42
 
43
-
43
+
44
44
  def save_playlist(path_to_save = nil)
45
45
  File.write("#{path_to_save || '.'}/Playlist-#{Time.now.to_a[3..5].join('-')}.yml", @playlist_data.to_yaml)
46
46
  end
@@ -1,3 +1,3 @@
1
1
  module Tubedl
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
@@ -12,11 +12,15 @@ Gem::Specification.new do |spec|
12
12
  spec.summary = %q{This gem parses youtube playlists to an object with an instance that named as playlist_data(hash: video_names => links)
13
13
  also can save that instance as yaml, can check a video link format with regex, can create link to specific resulation
14
14
  can take whole page data of a link, can take video ID from link and can save object as yaml and also can save a smplayer
15
- compatible playlist file. Now user can pass path to save playlist for yaml and smplalyewr playlists. }
15
+ compatible playlist file. Now user can pass path to save playlist for yaml and smpalyer playlists. SMPlayer can play youtube
16
+ and other online videos and while playing a plistlist it ill continue from previous session item and time so i hope
17
+ it will helpful for tutorial kind videos. }
16
18
  spec.description = %q{This gem parses youtube playlists to an object with an instance that named as playlist_data(hash: video_names => links)
17
19
  also can save that instance as yaml, can check a video link format with regex, can create link to specific resulation
18
20
  can take whole page data of a link, can take video ID from link and can save object as yaml can save a smplayer
19
- compatible playlist file. Now user can pass path to save playlist for yaml and smplalyewr playlists.}
21
+ compatible playlist file. Now user can pass path to save playlist for yaml and smplayer playlists. SMPlayer can play youtube
22
+ and other online videos and while playing a plistlist it will continue from previous session item and time so i hope
23
+ it will helpful for tutorial kind videos.}
20
24
  spec.homepage = "https://github.com/cptangry/tubedl"
21
25
  spec.license = "MIT"
22
26
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tubedl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gökhan Çağlar
@@ -70,7 +70,9 @@ description: |-
70
70
  This gem parses youtube playlists to an object with an instance that named as playlist_data(hash: video_names => links)
71
71
  also can save that instance as yaml, can check a video link format with regex, can create link to specific resulation
72
72
  can take whole page data of a link, can take video ID from link and can save object as yaml can save a smplayer
73
- compatible playlist file. Now user can pass path to save playlist for yaml and smplalyewr playlists.
73
+ compatible playlist file. Now user can pass path to save playlist for yaml and smplayer playlists. SMPlayer can play youtube
74
+ and other online videos and while playing a plistlist it will continue from previous session item and time so i hope
75
+ it will helpful for tutorial kind videos.
74
76
  email:
75
77
  - caglar.gokhan@gmail.com
76
78
  executables: []
@@ -129,5 +131,7 @@ summary: 'This gem parses youtube playlists to an object with an instance that n
129
131
  can check a video link format with regex, can create link to specific resulation
130
132
  can take whole page data of a link, can take video ID from link and can save object
131
133
  as yaml and also can save a smplayer compatible playlist file. Now user can pass
132
- path to save playlist for yaml and smplalyewr playlists.'
134
+ path to save playlist for yaml and smpalyer playlists. SMPlayer can play youtube
135
+ and other online videos and while playing a plistlist it ill continue from previous
136
+ session item and time so i hope it will helpful for tutorial kind videos.'
133
137
  test_files: []