Editing artist tag for an mp3 file based on filename - id3

I have files of the form "Song Artist - Song Title". For instance
Bastille - Pompeii (Kat Krazy Remix)
Iggy Azalea ft. Rita Ora - Black Widow
Sia - Chandelier
and I would like to edit their id3 tags so that the artist name is the string that comes before space dash space. So for the song "Sia - Chandelier" the artist would be "Sia". Is there a simple way to do this with a script? Thanks.

I use Mp3tag for such tasks.
In Mp3tag you will find the (id3tag) converter 'filename - tag'. If the filename appears in the form "Song Artist - Song Title", you can use the converter 'filename - tag' (ALT-2) with the formatstring "%artist% - %title%".
All the possible formatstrings are visible with a click on the little black arrow on the right side of the format string input box.
The preview has to show a valid result, otherwise the preview- and OK-button remains disabled.

Related

I need help in Python with displaying the contents of a 2D Set into a Tkinter Textbox

Disclaimer: I have only begun to learn about Python. I took a crash course just to learn the very basics about a month ago and the rest of my efforts to learn have all been research thru Google and looking at solutions here in Stack Overflow.
I am trying to create an application that will read all PDF files stored in a folder and extract their filenames, page numbers, and the contents of the first page, and store this information into a 2D set. Once this is done, the application will create a tkinter GUI with 2 listboxes and 1 text box.
The application should display the PDF filenames in the first listbox, and the corresponding page numbers of each file in the second listbox. Both listboxes are synched in scrolling.
The text box should display the text contents on the first page of the PDF.
What I want to happen is that each time I click a PDF filename in the first listbox with the mouse or with up or down arrow keys, the application should display the contents of the first page of the selected file in the text box.
This is how my GUI looks and how it should function
https://i.stack.imgur.com/xrkvo.jpg
I have been successful in all other requirements so far except the part where when I select a filename in the first listbox, the contents of the first page of the PDF should be displayed in the text box.
Here is my code for populating the listboxes and text box. The contents of my 2D set pdfFiles is [['PDF1 filename', 'PDF1 total pages', 'PDF1 text content of first page'], ['PDF2 filename', 'PDF2 total pages', 'PDF2 text content of first page'], ... etc.
===========Setting the Listboxes and Textbox=========
scrollbar = Scrollbar(list_2)
scrollbar.pack(side=RIGHT, fill=Y)
list_1.config(yscrollcommand=scrollbar.set)
list_1.bind("<MouseWheel>", scrolllistbox2)
list_2.config(yscrollcommand=scrollbar.set)
list_2.bind("<MouseWheel>", scrolllistbox1)
txt_3 = tk.Text(my_window, font='Arial 10', wrap=WORD)
txt_3.place(relx=0.5, rely=0.12, relwidth=0.472, relheight=0.86)
scrollbar = Scrollbar(txt_3)
scrollbar.pack(side=RIGHT, fill=Y)
list_1.bind("<<ListboxSelect>>", CurSelect)
============Populating the Listboxes with the content of the 2D Set===
i = 0
while i < count:
list_1.insert(tk.END, pdfFiles[i][0])
list_2.insert(tk.END, pdfFiles[i][1])
i = i + 1
============Here is my code for CurSelect function========
def CurSelect(evt):
values = [list_1.get(idx) for idx in list_1.curselection()]
print(", ".join(values)) ????
========================
The print command above is just my test command to show that I have successfully extracted the selected item in the listbox. What I need now is to somehow link that information to its corresponding page content in my 2D list and display it in the text box.
Something like:
1) select the filename in the listbox
2) link the selected filename to the filenames stored in the pdfFilename 2D set
3) once filename is found, identify the corresponding text of the first page
4) display the text of the first page of the selected file in the text box
I hope I am making sense. Please help.
You don't need much to finish it. You just need some small things:
1. Get the selected item of your listbox:
selected_indexes = list_1.curselection()
first_selected = selected_indexes[0] # it's possible to select multiple items
2. Get the corresponding PDF text:
pdf_text = pdfFiles[first_selected][2]
3. Change the text of your Text widget: (from https://stackoverflow.com/a/20908371/8733066)
txt_3.delete("1.0", tk.END)
txt_3.insert(tk.END, pdf_text)
so replace your CurSelect(evt) method with this:
def CurSelect(evt):
selected_indexes = list_1.curselection()
first_selected = selected_indexes[0]
pdf_text = pdfFiles[first_selected][2]
txt_3.delete("1.0", tk.END)
txt_3.insert(tk.END, pdf_text)

Adding a badge to an xpages applayout title bar node item

Is it possible to add a simple badge to a title bar node item? Each tab in my layout represents a separate application. My users would like to see a number next to the name on the tab to indicate whether there are documents in that application needing their attention. If no documents, then no badge, just the application name by itself. If there are documents, then display the application name and a badge for the number. I'm not finding a way to include the span tag in a PageLinkNode or BasicLinkNode.
PageLinkNode (xe:pageTreeNode) label can only be plain text.
You can use the image property though:
<xe:this.titleBarTabs>
<xe:pageTreeNode
page="..."
label="Application A"
image="#{javascript: var nr = 5;
nr > 0 ? ('badge' + Math.min(nr, 10) + '.gif') : ''}">
</xe:pageTreeNode>
Add to Resources/Images ten pictures badge1.gif, badge2.gif, ... badge10.gif with the numbers as pictures. badge10.gif would be a 9+ picture.
As an alternative, you could provide the number of documents as part of the label (e.g. "Your Application Name [23]") and convert it on client side onClientLoad event to HTML label + badge-span.

lwuit text area

I developed an RSS Application for two XML files and displayed it on two LWUIT Tabs. The problem is with my LWUIT TextArea, whenever I click on my ListForm (it contains titles from the RssFile), I need to display description information from the RSS File. First time I am able to display the description related to the title clicked in ListForm. If I click the ListForm the next time onwards I am able to display the same description again and again in the textarea..(Eventhough I am getting Related Description from RssFile)
Here is my Code:
private void displayCompleteNewsScreen(News detailNews) {
Label title = new Label(detailNews.getTitle());
form2.setTitleComponent(title);
String Description = detailNews.getDescription();
System.out.println("Description" + Description);//Here i am able to get different Description values Related to myList Screen but in text area it is displaying First one always
big = new TextArea();
big.setEditable(false);
big.setText(Description);
form2.addComponent(pubDate);
form2.addComponent(big);
form2.show();
}
As you are reusing form2 instance you should clear it in displayCompleteNewsScreen method. Call removeAll before calling setTitleComponent.
And don't forget to set form2 Commands again in displayCompleteNewsScreen.

How can I compile a list of unique image filenames in a set of html files?

I have ~3,600 html files with a ton of image tags in them. I'd like to be able to capture all the src attribute values used in these files and aggregate them into a text file where I can then remove duplicates and see how many unique image filenames there are overall.
I use BBEdit and I can easily use regex and multi-file search to find all the image references (18,673), but I don't want to replace them with anything -- instead, I want to capture them from the BBEdit search results 'Notes' and push them into another file.
Is this something that can be AppleScripted? Or are there other means to the same end that would be appropriate?
You've got a tall task there because there's many parts of this you have to solve. To give you a start, here's some advice on reading one html file and putting all the src images in an applescript list. You have to do much more than that but this is a beginning.
First you can read a html file into applescript as regular text. Something like this will get the text of one html file...
set theFile to choose file
set htmlText to read theFile
Once you have the text into applescript you could use text item delimiters to grab the src images. Here's an example. It should work no matter how complex the html code...
set htmlText to "<img src=\"smiley.gif\" alt=\"Smiley face\" height=\"42\" width=\"42\" />
<img src=\"smiley.gif\" alt=\"Smiley face\" height=\"42\" width=\"42\" />
<img src=\"smiley.gif\" alt=\"Smiley face\" height=\"42\" width=\"42\" />"
set text item delimiters to "src=\""
set a to text items of htmlText
if (count of a) is less than 2 then return
set imageList to {}
set text item delimiters to "\""
repeat with i from 2 to count of a
set thisImage to first text item of (item i of a)
set end of imageList to thisImage
end repeat
set text item delimiters to ""
return imageList
I hope that helps!

Big gaps, spaces between words in uiLabel text

I have made a uiLabel with a one single word as the text/title. The label is very long and turned 90 deg. It is added to a scrollView so you can see it all eventually.
My problem is; my text is centred, so i only see the word after scrolling down for a while. I need multiple copies of the word in my .text string with nice big spaces between them, so I can see the word on screen most of the time.
Is there a nice format to 'push' words apart like this without having to type in hundreds of spaces?
e.g. #"Label Title /big space/ Label Title /big space/ Label Title /big space/ Label Title"
I have got an idea. You can initialize the NSString variable used to set the title by using
[[NSString alloc] intiWithFormat:#"%# %# %# %#", string1,string2,string3 string4];

Resources