diff --git a/lib/remote/plugins/instagram.rb b/lib/remote/plugins/instagram.rb index 2d29a69..3677663 100644 --- a/lib/remote/plugins/instagram.rb +++ b/lib/remote/plugins/instagram.rb @@ -8,7 +8,16 @@ def url end def title - og_search 'description' + def clean(str) + str = str.gsub(/^([^#]*)#.*$/, '\\1') + .gsub(/^\W+/,'') + .gsub(/\W+$/,'').strip if str + str if str and not str.empty? + end + + title = clean(og_search 'title') + description = clean(og_search 'description') + description or title end end diff --git a/test/test_remote.rb b/test/test_remote.rb index df16037..ad7c264 100644 --- a/test/test_remote.rb +++ b/test/test_remote.rb @@ -31,7 +31,6 @@ def test_url_patterns 'Flickr' => ['http://www.flickr.com/photos/kintel/5693336211/'], 'Fukung' => ['http://fukung.net/v/6873/catparrot.jpg'], 'Imagenetz' => ['http://www.imagenetz.de/f7a20f74f/test_42x42.png.html'], - 'Imageshack' => ['http://imageshack.us/photo/my-images/20/test42x42.png/'], 'Imgur' => ['http://imgur.com/vXUwn'], 'Picpaste' => ['http://picpaste.com/test_42x42.png'], 'Soundcloud' => ['http://soundcloud.com/flux-pavilion/flux-pavilion-the-story-of-shadrok/'], @@ -53,20 +52,20 @@ def test_url_patterns def test_abload plugin = Loader::create 'http://www.abload.de/image.php?img=test_42x42nupq.png' - assert_match(plugin.url, %r{abload\.de/img/test_42x42nupq\.png}) + assert_match(%r{abload\.de/img/test_42x42nupq\.png}, plugin.url) test_remote_file plugin.url end def test_flickr plugin = Loader::create 'http://www.flickr.com/photos/dcdead/6072830085/?f=hp' - assert_match(plugin.url, /staticflickr\.com/) - assert_equal(plugin.title, 'Path To Light') + assert_match(/staticflickr\.com/, plugin.url) + assert_equal('Path To Light', plugin.title) end def test_fukung plugin = Loader::create 'http://fukung.net/v/6873/catparrot.jpg' - assert_equal(plugin.url, 'http://media.fukung.net/images/6873/catparrot.jpg') + assert_equal('http://media.fukung.net/imgs/catparrot.jpg', plugin.url) assert(plugin.tags.length > 0) end @@ -97,83 +96,67 @@ def test_twitter end end - def test_imagenetz - plugin = Loader::create 'http://www.imagenetz.de/f7a20f74f/test_42x42.png.html' - assert_match(plugin.url, %r{imagenetz\.de/img\.php\?file=}) - - test_remote_file plugin.url - end - - def test_imageshack - plugin = Loader::create 'http://imageshack.us/photo/my-images/20/test42x42.png/' - assert_match(plugin.url, %r{imageshack\.us/[^/]+/[^/]+/test42x42\.png}) - - test_remote_file plugin.url - end - def test_imgur plugin = Loader::create 'http://imgur.com/vXUwn' - assert_equal(plugin.url, 'http://i.imgur.com/vXUwn.png') + assert_equal('http://i.imgur.com/vXUwn.png', plugin.url) end =begin they delete images after a few weeks anyway def test_picpaste plugin = Loader::create 'http://picpaste.com/test_42x42.png' - assert_match(plugin.url, %r{http://picpaste.com/pics/test_42x42.\d+.png}) + assert_match(%r{http://picpaste.com/pics/test_42x42.\d+.png}, plugin.url) end =end def test_soundcloud plugin = Loader::create 'http://soundcloud.com/flux-pavilion/flux-pavilion-the-story-of-shadrok/' - assert_equal(plugin.title, "Flux Pavilion - The Story Of Shadrok") - assert_match(plugin.embed, %r{