diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 84da08d7b7fcda12c85caeb5a10b4903770a6f69 (patch) | |
tree | 2a6aea76f2dfffb4cc04bb907c4725af94f70e72 /noatun-plugins/luckytag | |
download | tdeaddons-84da08d7b7fcda12c85caeb5a10b4903770a6f69.tar.gz tdeaddons-84da08d7b7fcda12c85caeb5a10b4903770a6f69.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeaddons@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'noatun-plugins/luckytag')
-rw-r--r-- | noatun-plugins/luckytag/Makefile.am | 11 | ||||
-rw-r--r-- | noatun-plugins/luckytag/luckytag.cpp | 49 | ||||
-rw-r--r-- | noatun-plugins/luckytag/luckytag.h | 35 | ||||
-rw-r--r-- | noatun-plugins/luckytag/luckytag.plugin | 121 | ||||
-rw-r--r-- | noatun-plugins/luckytag/parsedmp3filename.cpp | 98 | ||||
-rw-r--r-- | noatun-plugins/luckytag/parsedmp3filename.h | 49 |
6 files changed, 363 insertions, 0 deletions
diff --git a/noatun-plugins/luckytag/Makefile.am b/noatun-plugins/luckytag/Makefile.am new file mode 100644 index 0000000..4e02899 --- /dev/null +++ b/noatun-plugins/luckytag/Makefile.am @@ -0,0 +1,11 @@ +INCLUDES= $(all_includes) +kde_module_LTLIBRARIES = noatunluckytag.la + +noatunluckytag_la_SOURCES = luckytag.cpp parsedmp3filename.cpp +noatunluckytag_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined +noatunluckytag_la_LIBADD = $(LIB_KFILE) -lnoatun -lnoatuntags + +noatunluckytag_la_METASOURCES = AUTO + +noatun_DATA = luckytag.plugin +noatundir = $(kde_datadir)/noatun diff --git a/noatun-plugins/luckytag/luckytag.cpp b/noatun-plugins/luckytag/luckytag.cpp new file mode 100644 index 0000000..d040659 --- /dev/null +++ b/noatun-plugins/luckytag/luckytag.cpp @@ -0,0 +1,49 @@ +// Copyright (c) 2001 Neil Stevens <multivac@fcmail.com> +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIAB\ILITY, WHETHER IN +// AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#include <noatun/app.h> +#include <noatun/playlist.h> +#include <noatun/player.h> +#include "luckytag.h" +#include "parsedmp3filename.h" + +extern "C" Plugin *create_plugin() +{ + return new LuckyTagger; +} + +LuckyTagger::LuckyTagger(void) : Tags(-10) +{ +} + +bool LuckyTagger::update(PlaylistItem &item) +{ + ParsedMP3FileName parsed(item.file()); + + if(parsed.title().length()) + item.setProperty("title", parsed.title()); + if(parsed.artist().length()) + item.setProperty("author", parsed.artist()); + if(parsed.album().length()) + item.setProperty("album", parsed.album()); + if(parsed.comment().length()) + item.setProperty("comment", parsed.comment()); + return true; +} + diff --git a/noatun-plugins/luckytag/luckytag.h b/noatun-plugins/luckytag/luckytag.h new file mode 100644 index 0000000..964cd8d --- /dev/null +++ b/noatun-plugins/luckytag/luckytag.h @@ -0,0 +1,35 @@ +// Copyright (c) 2001 Neil Stevens <multivac@fcmail.com> +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIAB\ILITY, WHETHER IN +// AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#ifndef LUCKYTAG_H +#define LUCKYTAG_H + +#include <noatun/plugin.h> +#include <noatun/tags.h> +#include <qobject.h> + +class LuckyTagger : public Tags, public Plugin +{ +public: + LuckyTagger(void); + + virtual bool update(PlaylistItem &item); +}; + +#endif diff --git a/noatun-plugins/luckytag/luckytag.plugin b/noatun-plugins/luckytag/luckytag.plugin new file mode 100644 index 0000000..1ed44ac --- /dev/null +++ b/noatun-plugins/luckytag/luckytag.plugin @@ -0,0 +1,121 @@ +Filename=noatunluckytag.la +Author=Frerich Raabe +Site=http://noatun.kde.org/ +Type=other +License=BSD +Name=Lucky Tag Reader +Name[af]=Gelukkig Etiket Leser +Name[ar]=قارئ العلامات المحظوظ +Name[az]=Lucky Taq Oxuyucusu +Name[bs]=Sretni čitač tagova +Name[ca]=Lector d'etiquetes Lucky +Name[cs]=Chytré čtení tagů +Name[cy]=Darllenydd Tag Lwcus +Name[da]=Heldig mærkelæser +Name[de]=Metainfo-Leser +Name[el]=Τυχερός αναγνώστης ετικετών +Name[eo]=Feliĉa etikedlegilo +Name[es]=Un bonito lector de etiquetas +Name[et]=Palainfo äraarvaja +Name[eu]=Lucky etiketa irakurgailua +Name[fa]=خوانندۀ برچسب خوششانس +Name[fi]=Onnekas tagien lukija +Name[fr]=Lecteur de balise +Name[fy]=Lokkige notysjelêzer +Name[gl]=Leitor de Marcas Lucky +Name[he]=קורא תגיות בר־מזל +Name[hi]=लकी टैग रीडर +Name[hr]=Lucky čitač oznaka +Name[is]=Heppni merkingalesarinn +Name[it]=Lettore Tag Lucky +Name[ja]=Lucky タグリーダー +Name[ka]=ბედნიერი ჭდის მკითხველი +Name[kk]=Мультимедиа файлының сипаттамаларын табу +Name[km]=កម្មវិធីអានស្លាក Lucky +Name[lt]=Sėkminga etikečių skaityklė +Name[mk]=Читач на ознаки на среќа +Name[ms]=Pembaca tag Bertuah +Name[nb]=Tagleser med flaks +Name[nds]=Metainfo-Leser +Name[ne]=भाग्यमानी ट्याग पाठक +Name[nl]=Gelukkige notitielezer +Name[nn]=Taglesar med lukke +Name[pl]=Zgadywacz oznaczeń plików +Name[pt]=Leitor de Marcas Lucky +Name[pt_BR]=Leitor de símbolos +Name[ro]=Cititor de taguri prin ghicire +Name[ru]=Теги из файла мультимедиа +Name[sk]=Lucky Tag čítačka +Name[sl]=Bralnik oznak Lucky Tag +Name[sr]=Читач срећних ознака +Name[sr@Latn]=Čitač srećnih oznaka +Name[sv]=Tursam taggläsare +Name[ta]=லக்கி ஒட்டு வாசிப்பாளர் +Name[tg]=Тег аз файли мултимедиа +Name[tr]=Luck Etiket Okuyucu +Name[uk]=Читач міток Lucky +Name[uz]=Laki teg oʻquvchi +Name[uz@cyrillic]=Лаки тэг ўқувчи +Name[vi]=Bộ đọc thẻ may +Name[xh]=Umfundi onentlahla weTag +Name[zh_CN]=幸运标签读取器 +Name[zh_TW]=幸運標籤閱讀器 +Comment=Guesses tag information from the filename +Comment[af]=Raaiskote etiket informasie van die lêernaam +Comment[ar]=يحزر معلومات العلامات من اسم الملف +Comment[az]=Fay adından taq mə'lumatını tapmağa çalışır +Comment[bg]=Отгатване на информацията за песните от името на файла +Comment[bs]=Pogađa informacije za tag iz imena datoteke +Comment[ca]=Intenta endevinar el contingut de l'etiqueta a partir del nom del fitxer +Comment[cs]=Odhaduje informace o značkách z názvu souboru +Comment[cy]=Dyfalu gwybodaeth tag o enw'r ffeil +Comment[da]=Gætter mærkeinformation fra filnavn +Comment[de]=Errät "auf gut Glück" Metainformationen aus dem Dateinamen +Comment[el]=Μαντεύει τις πληροφορίες ετικέτας από το όνομα του αρχείου +Comment[eo]=Divenas etikedan informon el la dosiernomo +Comment[es]=Obtiene información para la etiqueta a partir del nombre del archivo +Comment[et]=Oletab mängitava loo infot failinime põhjal +Comment[eu]=Etiketen informazioa fitxategi izenetik abiatuta igarten du +Comment[fa]=اطلاعات برچسب را از نام پرونده حدس میزند +Comment[fi]=Arvaa tagitiedot suoraan tiedostonimestä +Comment[fr]=Devine les informations de balises à partir du nom de fichier +Comment[fy]=Riedt de notysje-ynformaasje út de triemnamme +Comment[gl]=Adiviña a información das marcas a partir do nome do ficheiro +Comment[he]=ניחוש מידע התגיות מתוך שם הקובץ +Comment[hi]=फ़ाइल-नामों से टैग जानकारी का अंदाजा लगाता है +Comment[hr]=Nagađa podatke u oznaci iz naziva datoteke +Comment[hu]=Tag-információ a fájlnév alapján +Comment[is]=Giskar á lagamerkingar útfrá skráarheitum +Comment[it]=Indovina le informazioni dei tag dal nome del file +Comment[ja]=ファイル名からタグ情報を推測 +Comment[ka]=ჭდის ინფორმაციას ფაილის სახელიდან ხვდება +Comment[kk]=Мультимедиа файлының атауына жүгініп сипаттамаларын табу +Comment[km]=ព័ត៌មានស្លាក Guesses ពីឈ្មោះឯកសារ +Comment[lt]=Atspėja etiketės informaciją tiesiog iš bylos pavadinimo +Comment[mk]=Ги погодува информациите за ознаката од името на датотеката +Comment[ms]=Meneka maklumat tag dari nama fail +Comment[nb]=Gjetter tag-informasjon fra filnavnen +Comment[nds]=Raadt Betekerinformatschonen ut den Dateinaam +Comment[ne]=फाइलनामबाट ट्याग सूचना अनुमान गर्छ +Comment[nl]=Raadt de notitie-informatie uit de bestandsnaam +Comment[nn]=Gissar tag-informasjon frå filnamnet +Comment[pl]=Zgaduje oznaczenia dla pliku z jego nazwy +Comment[pt]=Adivinha a informação das marcas a partir do nome do ficheiro +Comment[pt_BR]=Informações de símbolos do nome do arquivo +Comment[ro]=Ghiceşte informaţiile de tag din numele de fişier +Comment[ru]=Получение тегов из файла +Comment[sk]=Háda tag informácie z názvu súborov +Comment[sl]=Informacije o značkah, uganjenih iz imena datoteke +Comment[sr]=Погађа информације о ознакама из имена фајла +Comment[sr@Latn]=Pogađa informacije o oznakama iz imena fajla +Comment[sv]=Gissar tagginformation från filnamnet +Comment[ta]=கோப்பு பெயரில் இருந்து கட்டளை தகவலை கண்டுபிடிக்கிறது +Comment[tg]=Гирифтани тегҳои аз файл +Comment[tr]=Dosya isminden etiketi bilgisini tahmin etmeye çalışır +Comment[uk]=Вгадує інформацію про мітку з назви файла +Comment[uz]=Teg maʼlumotini faylning nomidan taxmin qilish +Comment[uz@cyrillic]=Тэг маълумотини файлнинг номидан тахмин қилиш +Comment[vi]=Đoán thông tin thẻ từ tên tập tin +Comment[xh]=Iqikelela ulwazi lwe tag ukusuka kwi gama lefayile +Comment[zh_CN]=从文件名中猜测标签信息 +Comment[zh_TW]=從檔名猜測標籤 diff --git a/noatun-plugins/luckytag/parsedmp3filename.cpp b/noatun-plugins/luckytag/parsedmp3filename.cpp new file mode 100644 index 0000000..a3006bd --- /dev/null +++ b/noatun-plugins/luckytag/parsedmp3filename.cpp @@ -0,0 +1,98 @@ +// Copyright (c) 2001 Frerich Raabe <raabe@kde.org> +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIAB\ILITY, WHETHER IN +// AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#include "parsedmp3filename.h" + +#include <qstring.h> +#include <qstringlist.h> + +#include <kurl.h> + +ParsedMP3FileName::ParsedMP3FileName(const QString &path) +{ + KURL url = path; + + QString fileName = url.fileName(false); + m_directories = QStringList::split("/", url.directory()); + + if (fileName.startsWith("(") && fileName.contains(")")) + { + m_artist = fileName.mid(1, fileName.find(")") - 1); + m_title = fileName.right(fileName.length() - fileName.find(")") - 1); + validateArtist(); + } + else if (fileName.startsWith("[") && fileName.contains("]")) + { + m_artist = fileName.mid(1, fileName.find("]") - 1); + m_title = fileName.right(fileName.length() - fileName.find("]") - 1); + validateArtist(); + } + else if (fileName.contains("-")) + { + m_artist = fileName.left(fileName.find("-") - 1); + m_title = fileName.right(fileName.length() - fileName.find("-") - 1); + validateArtist(); + } + else + { + m_title = fileName; + m_album = m_directories.last(); + m_artist = m_directories[m_directories.count() - 2]; + } + + if (m_title.contains("(") && m_title.find(")", m_title.find("("))) + { + unsigned int start = m_title.find("("); + unsigned int end = m_title.find(")"); + m_comment = m_title.mid(start + 1, end - start - 1); + m_title.truncate(start); + } + + m_title = beautifyString(m_title); + if (m_title.right(4) == ".mp3") + m_title.truncate(m_title.length() - 4); + m_artist = beautifyString(m_artist); + m_album = beautifyString(m_album); + m_comment = beautifyString(m_comment); +} + +void ParsedMP3FileName::validateArtist() +{ + bool couldConvert; + if (m_artist.toUShort(&couldConvert) < 30 && couldConvert) + m_artist = m_directories[m_directories.count() - 2]; + m_album = m_directories.last(); +} + +QString ParsedMP3FileName::beautifyString(const QString &s) +{ + QString temp = s.lower().simplifyWhiteSpace(); + + temp[0] = temp[0].upper(); + + unsigned int numSpaces = temp.contains(" "); + unsigned int spacePos = 0; + while (numSpaces > 0) { + spacePos = temp.find(" ", spacePos == 0? 0 : spacePos + 1); + temp[spacePos + 1] = temp[spacePos + 1].upper(); + numSpaces--; + } + + return temp; +} diff --git a/noatun-plugins/luckytag/parsedmp3filename.h b/noatun-plugins/luckytag/parsedmp3filename.h new file mode 100644 index 0000000..5dc2809 --- /dev/null +++ b/noatun-plugins/luckytag/parsedmp3filename.h @@ -0,0 +1,49 @@ +// Copyright (c) 2001 Frerich Raabe <raabe@kde.org> +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIAB\ILITY, WHETHER IN +// AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#ifndef PARSEDMP3FILENAME_H +#define PARSEDMP3FILENAME_H + +#include <qstringlist.h> + +class ParsedMP3FileName +{ +public: + ParsedMP3FileName(const QString &); + ~ParsedMP3FileName() {} + + QString title() const { return m_title; } + QString artist() const { return m_artist; } + QString album() const { return m_album; } + QString comment() const { return m_comment; } + +protected: + QString m_title; + QString m_artist; + QString m_album; + QString m_comment; + +private: + void validateArtist(); + QString beautifyString(const QString &); + + QStringList m_directories; +}; + +#endif |